out of dom vs documentfragment (v42)

Revision 42 of this benchmark created on


Preparation HTML

<div id="list">
</div>

Teardown


    document.getElementById('list').innerHTML = "";
  

Test runner

Ready to run.

Testing in
TestOps/sec
out of dom
var list = document.getElementById('list'),
  elem = document.createElement('div');

list.innerHTML = "";
for (var i = 0; i < 1000; i++) {
  a = document.createElement('a');
  a.innerHTML = 'link ' + i;
  a.style.display = 'block';
  elem.appendChild(a);
}
document.body.replaceChild(elem, list);
ready
documentfragment
var elem = document.createDocumentFragment();

for (var i = 0; i < 1000; i++) {
  a = document.createElement('a');
  a.innerHTML = 'link ' + i;
  a.style.display = 'block';
  elem.appendChild(a);
}
document.getElementById('list').appendChild(elem);
ready
one by one
var list = document.getElementById('list');

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

Revisions

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