Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Test (innerHTML, replaceChildren, remove, removeChild)
(version: 1)
Test (innerHTML, replaceChildren, remove, removeChild)
Comparing performance of:
innerHTML vs replaceChildren vs remove vs removeChild
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<div id="parent"></div>
Script Preparation code:
const node = document.getElementById('parent'); const child = document.createElement('div') child.textContent = 'some text' for(var i = 0; i < 5000; i++) node.appendChild(child);
Tests:
innerHTML
const node = document.getElementById('parent'); node.innerHTML = '';
replaceChildren
const node = document.getElementById('parent'); node.replaceChildren();
remove
const node = document.getElementById('parent'); while(node.firstChild) node.firstChild.remove()
removeChild
const node = document.getElementById('parent'); while(node.firstChild) node.removeChild(node.firstChild)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
innerHTML
replaceChildren
remove
removeChild
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Browser/OS:
Chrome 143 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
innerHTML
7039120.5 Ops/sec
replaceChildren
7248584.5 Ops/sec
remove
25336824.0 Ops/sec
removeChild
25380414.0 Ops/sec
Related benchmarks:
innerhtml vs removechild
innerhtml vs removechild
innerhtml vs removechild
innerhtml vs removechild
innerhtml vs removechild
innerhtml vs removechild vs replacechildren
innerhtml vs removechild vs remove vs innerText vs textContent vs replaceChildren
innerhtml vs removechild vs remove vs innerText vs textContent vs replaceChildren (100)
Test (while or forEach)
Comments
Confirm delete:
Do you really want to delete benchmark?