ブラウザの大量データレンダリングスキーム

1088 ワード





    
    
    
    Document



    
setTimeout(() => { // const total = 100000 // 20 , const once = 20 // const loopCount = total / once let countOfRender = 0 let ul = document.querySelector("ul"); function add() { // , const fragment = document.createDocumentFragment(); for (let i = 0; i < once; i++) { const li = document.createElement("li"); li.innerText = Math.floor(Math.random() * total); fragment.appendChild(li); } ul.appendChild(fragment); countOfRender += 1; loop(); } function loop() { if (countOfRender < loopCount) { window.requestAnimationFrame(add); } } loop(); }, 0);