DOM vs innerHTML (v31)

Revision 31 of this benchmark created on


Description

Fine tuning the DOM method to yield better performance for this particular synthetic test. (alternate method without cloning)

Preparation HTML

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

Setup

document.getElementById('main_node').innerHTML = '';

Teardown


    document.getElementById('main_node').innerHTML = '';
  

Test runner

Ready to run.

Testing in
TestOps/sec
DOM
for (var i=0; i<1000; i++) {
node.appendChild(document.createElement('div'));
}
 
ready
innerHTML
var s = '';
for (var i=0; i<1000; i++) {
  s+= '<div></div>';
}
node.innerHTML = s;
ready

Revisions

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