replaceChild vs insertBefore & removeChild

JavaScript performance comparison

Revision 3 of this test case created by

Preparation code

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

Preparation code output

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

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
replaceChild
var d = document.getElementById('test');

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

d.replaceChild(sp2, sp1);
pending…
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);
pending…

Compare results of other browsers

Revisions

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

0 Comments