jquery selector speed

JavaScript performance comparison

Revision 92 of this test case created

Preparation code

<table width="600">
  <tr>
    <td>
      Text
    </td>
  </tr>
  <tr>
    <td>
      <img src="demo.jpg" width="200" height="200" />
    </td>
  </tr>
  <tr>
    <td style="font:arial;">
      <img src="demo.jpg" width="200" height="200" />
    </td>
  </tr>
  <tr>
    <td style="font:arial;">
      <a href="#">
      <img src="demo.jpg" width="200" height="200"/>
      </a>
    </td>
  </tr>
</table>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>

Preparation code output

Text

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
:has
$('td:has(img)').css('border', '1px solid red');
pending…
.has
$('td').has('img').css('border', '1px solid red');
pending…
.closest
$("img").closest("td").css('border', '1px solid red');
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