jquery visible test (v8)

Revision 8 of this benchmark created by Aaron on


Description

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

Preparation HTML

<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>

Test runner

Ready to run.

Testing in
TestOps/sec
:visible
var spans = $('.test-span:visible');
ready
normal
var spans = $('.test-span');
ready
two classes
var spans = $('.test-span.visi');
ready
two classes not
var spans = $('.test-span:not(.notvisi)');
ready
filter
var spans = $('.test-span').filter(':visible');
ready

Revisions

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