.innerHTML vs DOM vs DocumentFragment

JavaScript performance comparison

Test case created

Preparation code

<div id="append"></div>
<script>
Benchmark.prototype.setup = function() {
    var el = document.getElementById('append');
};
</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.appendChild
//el.appendChild(document.createElement('div'));
pending…
fragment.appendChild
var fragment = document.createDocumentFragment();
fragment.appendChild(document.createElement('div'));
el.appendChild(fragment);
pending…
el.innerHTML
el.innerHTML += '<div/>';
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