Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Append children VS appendChild in loop VS replaceChildren moar
(version: 1)
Comparing performance of:
append vs appendChild in loop vs replaceChildren
Created:
8 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<div id="root"></div>
Script Preparation code:
const root = document.getElementById('root'); const numChildren = 100; const children = []; for (let i = 0; i < numChildren; i++) { children[i] = document.createElement('span'); }
Tests:
append
root.append(...children);
appendChild in loop
for (let i = 0; i < numChildren; i++) { root.appendChild(children[i]); }
replaceChildren
root.replaceChildren(...children)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
append
appendChild in loop
replaceChildren
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
8 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:141.0) Gecko/20100101 Firefox/141.0
Browser/OS:
Firefox 141 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
append
373.8 Ops/sec
appendChild in loop
947.9 Ops/sec
replaceChildren
383.0 Ops/sec
Related benchmarks:
Remove children
childNodes vs children vs firstChild vs firstElementChild
insertAdjacentHTML VS append VS appendChild (createDocumentFragment) [MINIMAL]
JS: append vs appendChild for multiple children
Spread vs Array.from on NodeList
Append children or appendChild in loop
Append children VS appendChild in loop VS replaceChildren
replaceChildren vs while w/ appendChild 2
Test (while or forEach)
Comments
Confirm delete:
Do you really want to delete benchmark?