advertisement

Article:
  Dynamic HTML Tables: Improving Performance
Subject:   Improvement for Approach #4 (True Cross-Browser Approaches)
Date:   2004-08-06 17:16:01
From:   morph268
If you use array to do string concatenation for option no:4; it will improve the performance significantly ( 141 mSec compare to 1266 mSec )


sample code:


var output = new Array();
output[output.length]= "<table id='myTable1'><tbody id='myTbody'>";
for (var j = 0; j < tableData.length; j++) {
output[output.length]="<tr class='tr" + (j%2) + "'>";
output[output.length]= "<td class='col0'>" + tableData[j].alpha + "</td>";
output[output.length]= "<td class='col1'>" + tableData[j].beta + "</td>";
output[output.length]= "<td class='col2'>" + tableData[j].gamma + "</td>";
output[output.length]= "<td class='col3'>" + tableData[j].delta + "</td>";
output[output.length]= "<td class='col4'>" + tableData[j].epsilon + "</td></tr>";
}
output[output.length]= "</tbody></table>";
document.getElementById("tableWrap").innerHTML = output.join();