createDocumentFragment vs. createElement

JavaScript performance comparison

Test case created by Alexander Behrens

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
createElement
var element = document.createElement("div");

for (var i = 0; i < 10; i++) {
  var div = document.createElement("div");
  div.innerHTML = "headline " + i;
  div.style.display = "none";
  element.appendChild(div);
}

document.body.appendChild(element);
pending…
createDocumentFragment
var fragment = document.createDocumentFragment();
var element = document.createElement("div");

fragment.appendChild(element);

for (var i = 0; i < 10; i++) {
  var div = document.createElement("div");
  div.innerHTML = "headline " + i;
  div.style.display = "none";
  element.appendChild(div);
}

document.body.appendChild(fragment);
pending…

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

Compare results of other browsers

0 Comments