Skip to content

Instantly share code, notes, and snippets.

@aarongustafson
Created December 6, 2009 14:54
Show Gist options
  • Save aarongustafson/250251 to your computer and use it in GitHub Desktop.
Save aarongustafson/250251 to your computer and use it in GitHub Desktop.
documentFragment can be useful for avoiding repeated reflows/repaints
var i, temp,
frag = document.createDocumentFragment(),
li = document.createElement('li');
for ( i=0; i<3; i++ )
{
temp = li.cloneNode( true );
temp.appendChild(
document.createTextNode(
'This is new list item number ' + ( i + 1 )
)
);
frag.appendChild( temp );
}
document.getElementById('the-list').appendChild( frag );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment