jquery selector speed (v92)

Revision 92 of this benchmark created on


Preparation HTML

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

Test runner

Ready to run.

Testing in
TestOps/sec
:has
$('td:has(img)').css('border', '1px solid red');
ready
.has
$('td').has('img').css('border', '1px solid red');
ready
.closest
$("img").closest("td").css('border', '1px solid red');
ready

Revisions

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