jQuery find performance

JavaScript performance comparison

Revision 4 of this test case created by Pooja Shah

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<table id="tbl" style="border: solid 1px black">
  <tr>
    <td class="class1">
      1
    </td>
    <td class="class2">
      a
    </td>
  </tr>
  <tr>
    <td class="class1">
      2
    </td>
    <td class="class2">
      b
    </td>
  </tr>
  <tr>
    <td class="class1">
      3
    </td>
    <td class="class2">
      c
    </td>
  </tr>
</table>

Preparation code output

1 a
2 b
3 c

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Separate finds
$('#tbl').find('.class1').hide();
$('#tbl').find('.class2').hide();
pending…
1 find
$('#tbl').find('.class1,.class2').hide();
pending…
through traversing
$('tbl.class1').each(function(index) {
  $(this).hide();
});
$('tbl.class2').each(function(index) {
  $(this).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. Here’s a list of current revisions for this page:

0 comments

Add a comment