createDocumentFragment vs appendChild on non-appended element

JavaScript performance comparison

Revision 7 of this test case created

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Normal Append
var form = document.createElement('form');
document.body.appendChild(form);

for (var i = 0; i < 1000; i++) {
  form.appendChild(d.createElement('input'));
}

document.body.removeChild(form);
pending…
Document Fragment
var form = document.createElement('form');
document.body.appendChild(form);

var frag = document.createDocumentFragment();

for (var i = 0; i < 1000; i++) {
  frag.appendChild(d.createElement('input'));
}

form.appendChild(frag);

d.body.removeChild(form);
pending…
Normal Append Last
var form = document.createElement('form');

for (var i = 0; i < 1000; i++) {
  form.appendChild(d.createElement('input'));
}

document.body.appendChild(form);
document.body.removeChild(form);
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