jQuery Multiple Selector vs selector plus find performance

JavaScript performance comparison

Revision 3 of this test case created by John Papa

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<div class="test" id="test">
  <script>
    var html = '<div id="someId">';
    for ( var j = 0; j < 20; j++ ) {
      html += '<div class="iconPersonRemove">';

      for ( var i = 0; i < 1000; i++ ) {
        html += '<div class="hasHidden"></div>';
      }

      html += '</div>';
    }
    html += '</div>';
    document.write( html );
  </script>
</div>

    

Preparation code output

<div class="test" 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
$('').find - 1.4.4
$('#someId').find('.iconPersonRemove').hasClass('hidden');
pending…
$('') - 1.4.4
$('#someId .iconPersonRemove').hasClass('hidden');
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