insertAdjacentHTML

JavaScript performance comparison

Test case created

Info

node.insertAdjacentHTML performance

Preparation code

<div id="work"></div>
<script>
  var work = document.getElementById("work");
</script>
<script>
Benchmark.prototype.setup = function() {
    while (work.hasChildNodes()){
     work.removeChild(work.firstChild);
    }
};
</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
insertAdjacentHTML
work.insertAdjacentHTML("BeforeEnd", "<span>test</span>");
pending…
innerHTML
work.innerHTML += "<span>test</span>";
pending…
appendChild
var s = document.createElement("span");
s.appendChild(document.createTextNode("test"));
work.appendChild(s);
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:

1 comment

Inviz commented :

For a larger chunks of HTML, documentFragment may be used to do the same DOM manipulation over a fragment built off HTML

Add a comment