Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
JS: replaceWith vs replaceChild2
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0
Browser:
Firefox 129
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
replaceWith
336827.3 Ops/sec
replaceChild
372624.4 Ops/sec
HTML Preparation code:
<div id="container"><p></p></div>
Script Preparation code:
var container = document.getElementById("container");
Tests:
replaceWith
var paragraph = document.createElement("p"); var existingp = container.querySelector("p"); existingp.replaceWith(paragraph);
replaceChild
var paragraph = document.createElement("p"); var existingp = container.querySelector("p"); container.replaceChild(paragraph, existingp);