jquery visible test

JavaScript performance comparison

Test case created

Info

http://stackoverflow.com/questions/4696779/performance-of-jquery-visible

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="test-content"></div>
<script>
  $(function() {
   for (var i = 200; i--;) {
    $('<span />', {
     style: "display:" + ((i % 2) ? 'block' : 'none'),
     class: "test-span" + ((i % 2) ? ' visi' : ' notvisi'),
     text: i
    }).appendTo('#test-content');
   }
  });
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
:visible
var spans = $('.test-span:visible');
pending…
normal
var spans = $('.test-span');
pending…
two classes
var spans = $('.test-span.visi');
pending…
two classes not
var spans = $('.test-span:not(.notvisi)');
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. Here’s a list of current revisions for this page:

0 comments

Add a comment