cloneNode vs innerHTML redo

JavaScript performance comparison

Test case created

Preparation code

<div id="container" style="display: none;"></div>
<script>
Benchmark.prototype.setup = function() {
    var container = document.getElementById('container'),
        prototype = document.createElement('div'),
        prototype_copy,
        html = "<p>Adding some <strong>arbitrary</strong> " +
               "HTML in here just to illustrate.</p> " +
               "<p>Some <span>nesting</span> too.</p> " +
               "<p>CloneNode doesn't care how the initial " +
               "nodes are created.</p>";
};
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
el.cloneNode(true)
prototype.innerHTML = html;

prototype_copy = prototype.cloneNode(true);
prototype_copy.id = 'whatever';

container.appendChild(prototype_copy);
pending…
el.innerHTML
container.innerHTML += html;
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:

0 comments

Add a comment