DOM vs innerHTML (v9)

Revision 9 of this benchmark created by gonchuki on


Description

Fine tuning the DOM method to yield better performance for this particular synthetic test.

Preparation HTML

<div id="main_node"></div>
<script>
  var node = document.getElementById('main_node'),
      fragment = document.createDocumentFragment();
  child = document.createElement('div');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
DOM
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));
fragment.appendChild(child.cloneNode(false));

node.appendChild(fragment);

node.innerHTML = '';
ready
innerHTML
node.innerHTML = '<div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>';

node.innerHTML = '';
ready

Revisions

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