Avoid Excessive Specificity

JavaScript performance comparison

Test case created by DareBoost

Preparation code

<div></div>
<div>
  <div></div>
  <div class="data">
    <table class="attendees">
      <tr>
        <th></th>
        <th></th>
        <th></th>
      </tr>
      <tr>
        <td class="gonzalez"></td>
        <td class="gonzalez"></td>
        <td class="gonzalez"></td>
      </tr>
      <tr>
        <td></td>
        <td></td>
        <td class="gonzalez"></td>
      </tr>
      <tr>
        <td class="gonzalez"></td>
        <td></td>
        <td class="gonzalez"></td>
      </tr>
    <table>
    <table class="attendees">
      <tr>
        <th></th>
        <th></th>
      </tr>
      <tr>
        <td></td>
        <td class="gonzalez"></td>
      </tr>
      <tr>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td class="gonzalez"></td>
        <td class="gonzalez"></td>
      </tr>
    </table>
  </div>
  <div></div>
</div>
<div class="data"></div> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

    

Preparation code output

<div></div> <div> <div></div> <div class="data"> <table class="attendees"> <tr> <th></th> <th></th> <th></th> </tr> <tr> <td class="gonzalez"></td> <td class="gonzalez"></td> <td class="gonzalez"></td> </tr> <tr> <td></td> <td></td> <td class="gonzalez"></td> </tr> <tr> <td class="gonzalez"></td> <td></td> <td class="gonzalez"></td> </tr> <table> <table class="attendees"> <tr> <th></th> <th></th> </tr> <tr> <td></td> <td class="gonzalez"></td> </tr> <tr> <td></td> <td></td> </tr> <tr> <td class="gonzalez"></td> <td class="gonzalez"></td> </tr> </table> </div> <div></div> </div> <div class="data"></div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
3 selectors
$( ".data table.attendees td.gonzalez" );
pending…
2 selectors
$( ".data td.gonzalez" );
pending…
1 selector
$( "td.gonzalez" );
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.

0 Comments