Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
appendChild cycles vs documentFragment
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Browser:
Chrome 119
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
appendChild w/ requestAnimationFrame
1.2M/s
append documentFragment w/ requestAnimationFrame
126K/s
appendChild
94K/s
append documentFragment
81K/s
View exact numbers
Test name
Executions per second
✓
appendChild w/ requestAnimationFrame
1,207,436 Ops/sec
append documentFragment w/ requestAnimationFrame
126,065 Ops/sec
appendChild
94,107 Ops/sec
append documentFragment
80,615 Ops/sec
HTML Preparation code:
<div id="container"></div>
Script Preparation code:
var container = document.getElementById('container'); var childrenAmount = 20; var childrenToAppend = []; for(let i = 0; i < childrenAmount; i++) { childrenToAppend.push(document.createElement('div')) }
Tests:
appendChild
childrenToAppend.forEach(child => container.appendChild(child));
append documentFragment
var fragment = document.createDocumentFragment(); childrenToAppend.forEach(child => fragment.appendChild(child)); container.appendChild(fragment)
appendChild w/ requestAnimationFrame
requestAnimationFrame(() => { childrenToAppend.forEach(child => container.appendChild(child)); })
append documentFragment w/ requestAnimationFrame
var fragment = document.createDocumentFragment(); childrenToAppend.forEach(child => fragment.appendChild(child)); requestAnimationFrame(() => { container.appendChild(fragment) })