out of dom vs documentfragment (v7)

Revision 7 of this benchmark created by Yin on


Preparation HTML

<div id="list1">
</div>
<div id="list2">
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
out of dom
var list = document.getElementById('list1');

list.innerHTML = "";
for (var i = 0; i < 500; i++) {
  a = document.createElement('a');
  a.innerHTML = 'link ' + i;
  a.style.display = 'block';
  list.appendChild(a);
}
ready
documentfragment
var list = document.getElementById('list2'),
    frag = document.createDocumentFragment();

list.innerHTML = "";
for (var i = 0; i < 500; i++) {
  a = document.createElement('a');
  a.innerHTML = 'link ' + i;
  a.style.display = 'block';
  frag.appendChild(a);
}

list.appendChild(frag);
ready

Revisions

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