Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
replaceWith vs replaceChild x1000
(version: 0)
replace dom
Comparing performance of:
replaceWith vs replaceChild
Created:
3 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<html> </html>
Script Preparation code:
parentBox = document.createElement('div'); document.body.appendChild(parentBox);
Tests:
replaceWith
var Iframe1 = []; var Video1 = []; for (var i = 0; i < 1000; i++) { Iframe1[i] = document.createElement('iframe'); parentBox.appendChild(Iframe1[i]); Video1[i] = document.createElement('video'); } for (var w = 9; w > -1; w--) { Iframe1[w].replaceWith(Video1[w]); }
replaceChild
var Iframe2 = []; var Video2 = []; for (var i = 0; i < 1000; i++) { Iframe2[i] = document.createElement('iframe'); parentBox.appendChild(Iframe2[i]); Video2[i] = document.createElement('video'); } for (var c = 9; c > -1; c--) { parentBox.replaceChild(Video2[c], Iframe2[c]); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
replaceWith
replaceChild
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Browser/OS:
Chrome 133 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
replaceWith
8.8 Ops/sec
replaceChild
7.3 Ops/sec
Related benchmarks:
remove lastChild vs replaceWith
replaceChildren vs documentFragment [2]
replacechildren vs appendchild
JS: replaceWith vs replaceChild2
clear element using replaceChildren vs removeChild
Comments
Confirm delete:
Do you really want to delete benchmark?