Element creation and class hidding

JavaScript performance comparison

Revision 26 of this test case created by

Preparation code

<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
var $jq = jQuery.noConflict();
</script>
    

Preparation code output

<script> var $jq = jQuery.noConflict(); </script>

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
Vanilla JS
var i;
for (i = 0; i < 100; i++) {
  var div = document.createElement('div');
  div.innerHTML = 'Hello ' + i;
  div.className = 'test';  
  document.body.appendChild(div);
}

var divs = document.querySelectorAll('test');
Array.prototype.forEach.call(divs ,function(div) {
  div.setAttribute('hidden', true);
});
pending…
jQuery
var i;
var body = $jq('body')
for (i = 0; i < 100; i++) {
 body.append('<div class="test">Hello ' + i + '</div>');
}

body.children('test').hide();
pending…

Compare results of other browsers

Revisions

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

0 Comments