Appending HTML

Benchmark created by thrigs on


Preparation HTML

<div id="output" />

Setup

var arr = [];
    for (var i = 0; i < 1000; i++) {
      arr.push(i);
    }

Teardown


    delete arr;
    document.getElementById("output").innerHTML = "";
  

Test runner

Ready to run.

Testing in
TestOps/sec
innerHTML
var results = document.getElementById("output");
for (var i in arr) {
  results.innerHTML += "<span>" + i + "</span>";
}
ready
insertAdjacentHTML
var results = document.getElementById("output");
for (var i in arr) {
  results.insertAdjacentHTML("beforeend", "<span>" + i + "</span>");
}
ready

Revisions

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

  • Revision 1: published by thrigs on