replaceChild vs removeChild
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var A=[],l,q,w,g=document.createElement("DIV"),c;
g.innerHTML='Em replaced!';
function r(){
A=[];
c=document.createElement("DIV")
for(var n=0;n!=200;n++){
w=document.createElement("DIV");
w.innerHTML=n;
c.appendChild(w);
A.push(w);
}
document.body.appendChild(c);
l=A.length;
}
r();
};
Benchmark.prototype.teardown = function() {
c.parentNode.removeChild(c)
r();
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
removeChild |
|
pending… |
replaceChild |
|
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. Here’s a list of current revisions for this page:
- Revision 1: published
- Revision 2: published by Erick RIbeiro
1 comment
Dont work