Performance improvement for getRenderedContents

Instead of calling $.append for every single char - buffer and call $.append only when really needed.

Change-Id: I53acfa795ea5dc6a8ca39ce11017daa85c9151d2
Merge "Performance improvement for getRenderedContents"