Created
March 15, 2018 15:53
-
-
Save a1exlism/1df1a59dd1edceb46dccdb4f64839b52 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
* ul insert 1000 li tag | |
*/ | |
let ul = document.querySelectorAll('.list'); | |
console.time('no frag'); | |
for(let i = 0; i < 1000; ++i) { | |
let li = document.createElement('li'); | |
li.textContent = 'No ' + i; | |
ul[0].appendChild(li); | |
} | |
console.timeEnd('no frag'); | |
console.time('with frag'); | |
let tmpLilist = document.createDocumentFragment(); | |
for(let i = 0; i < 1000; ++i) { | |
let li = document.createElement('li'); | |
li.textContent = 'No ' + i; | |
tmpLilist.appendChild(li); | |
} | |
ul[1].appendChild(tmpLilist); | |
console.timeEnd('with frag'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment