Why is building a table with the DOM slower than using an array? IOW,
why is
var table=document. createDocumentF ragment();
for( var i=0; i < 4000; i++ ) {
tr=table.insert Row( table.rows.leng th );
td=tr.appendChi ld( document.create Element('td') );
td.appendChild( 'foo' );
}
someElement.app endChild( table );
much slower than
var table[];
table.push( "<table>" );
for( var i=0; i < 4000; i++ ) {
table.push( "<tr>" );
table.push( "<td>foo</td>" );
table.push( "</tr>" );
}
table.push( "</table>" );
document.writel n( table.join('') ); // thanks again for the tip!!
? Am I doing something inadvisable with the document object?
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
why is
var table=document. createDocumentF ragment();
for( var i=0; i < 4000; i++ ) {
tr=table.insert Row( table.rows.leng th );
td=tr.appendChi ld( document.create Element('td') );
td.appendChild( 'foo' );
}
someElement.app endChild( table );
much slower than
var table[];
table.push( "<table>" );
for( var i=0; i < 4000; i++ ) {
table.push( "<tr>" );
table.push( "<td>foo</td>" );
table.push( "</tr>" );
}
table.push( "</table>" );
document.writel n( table.join('') ); // thanks again for the tip!!
? Am I doing something inadvisable with the document object?
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
Comment