I have a page on my site that uses JS to write out a lot of dynamic content via strings that are then parsed as HTML. Works great in all browsers, but IE6 is incredibly slow. Many users end up getting the “script is unresponsive, would you like to abort?” message.
I’ve tried using arrays instead of strings to see if IE6 handles those better, but I still get about the same performance. I was wondering if anyone had any clever ideas on how this can be optimized for IE6, or otherwise prevent that unresponsive script message from appearing.
function createTable(){
var tableStr = "<table><tbody>";
tableStr += "</tbody></table>";
for(var x=0; x<contentData.length;x++){
tableStr += createRow(contentData[x]);
}
$("#content").html(tableStr);
}
function createRow(data){
var rowStr = "<tr>";
rowStr += "<td>" + data.name + "</td>";
rowStr += "<td>" + data.address + "</td>";
rowStr += "<td>" + data.phone + "</td>";
rowStr += "<td>" + data.fax + "</td>";
rowStr += "</tr>";
return rowStr;
}
Look this post with recommendations on how to improve Javascript performance for IE