find vs direct

JavaScript performance comparison

Revision 8 of this test case created by Mohit Seth

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<table id="my_table">
  <tr>
    <td class="test">
      Test
    </td>
  </tr>
  <tr>
    <td class="test">
      Test
    </td>
  </tr>
  <tr>
    <td class="test">
      Test
    </td>
  </tr>
</table>

Preparation code output

Test
Test
Test

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Find
$('td.test', $('#my_table'))
pending…
Direct
$('#my_table .test');
pending…
More Direct
$('#my_table td.test')
pending…
find-2
$("#my_table").find('td.test');
pending…
Another direct
$("#my_table>.test");
pending…
children
$("#my_table").children('.test');
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