replaceChild vs insertBefore & removeChild (v3)

Revision 3 of this benchmark created on


Preparation HTML

<div id='test'></div>

Test runner

Ready to run.

Testing in
TestOps/sec
replaceChild
var d = document.getElementById('test');

var sp1 = document.createElement("span");
d.appendChild(sp1);
var sp2 = document.createElement("span");

d.replaceChild(sp2, sp1);
ready
removeChild + appendChild
var d = document.getElementById('test');

var sp1 = document.createElement("span");
d.appendChild(sp1);
var sp2 = document.createElement("span");

d.removeChild(sp1);
d.appendChild(sp2);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.