jQuery Multiple Selector vs selector plus find performance (v3)

Revision 3 of this benchmark created by John Papa on


Preparation HTML

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

Test runner

Ready to run.

Testing in
TestOps/sec
$('').find - 1.4.4
$('#someId').find('.iconPersonRemove').hasClass('hidden');
 
ready
$('') - 1.4.4
$('#someId .iconPersonRemove').hasClass('hidden');
 
ready

Revisions

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