Doing many string concatenation operations can be a major hit on performance even in Javascipt.
Using + to concatenate string pieces into a huge string is not the correct and the only way. Since string concatenation results in too many intermediate strings and concatenation operations, it performs poorly.
A better approach for string concatenation is using Array.join(), which joins all array elements into one string:
var tmp = ;
for (/* each piece */)
str = tmp.join('');
This method doesn't suffer from the intermediate strings, and executes faster with high number of concatenation operations.
Want automatic updates?
Subscribe to our RSS feed
Get Email Updates
sent directly to your inbox!