Created
May 9, 2011 07:37
-
-
Save sindre/962201 to your computer and use it in GitHub Desktop.
JS createDocumentFragment to avoid reflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://www.slideshare.net/nzakas/high-performance-javascript-amazon-devcon-2011 | |
var list = document.getElementsByClassName('items')[0], | |
fragment = document.createDocumentFragment(), | |
i, item; | |
for (i=0; i < 10; i++) { | |
item = document.createElement('li'); | |
item.innerHTML = 'item #'+i; | |
fragment.appenChild(item); | |
} | |
list.appenChild(fragment); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment