docfrag

JavaScript performance comparison

Test case created by kzhouTL

Preparation code

<div id='test'></div>
      
<script>
Benchmark.prototype.setup = function() {
  var div = document.createElement('div');
  div.innerHTML = 'helloWorld';
  var iframe = document.createElement('iframe');
  iframe.innerHTML = 'helloWorld';
  var video = document.createElement('video');
  video.innerHTML = 'helloWorld';
  var img = document.createElement('img');
  img.innerHTML = 'helloWorld';
  
  var tempDiv = document.createElement('div');
  var fragment = document.createDocumentFragment();
  var testDiv = document.querySelector('#test');

};

Benchmark.prototype.teardown = function() {
  document.querySelector('#test').innerHTML = '';

};
</script>

Preparation code output

<div id='test'></div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
multiple appends
testDiv.appendChild(div);
testDiv.appendChild(iframe);
testDiv.appendChild(video);
testDiv.appendChild(img);
pending…
one append
tempDiv.appendChild(div);
tempDiv.appendChild(iframe);
tempDiv.appendChild(video);
tempDiv.appendChild(img);
testDiv.appendChild(tempDiv);
pending…
docfrag
fragment.appendChild(div);
fragment.appendChild(iframe);
fragment.appendChild(video);
fragment.appendChild(img);
testDiv.appendChild(fragment);
pending…

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

Compare results of other browsers

0 Comments