SizzleSimplicity

JavaScript performance comparison

Test case created by Josh

Info

Compare simple selectors to more precise selectors in jQuery operations

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div class='listContainer'>
  <ul class='topUL'>
    <li>
    </li>
    <li>
      <div>
        Header
        <ul data-secondul='sample data' class='secondUL'>
          <li>
          </li>
        </ul>
      </div>
    </li>    
  </ul>
</div>

Preparation code output

  • Header

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Specific
var el = $('.listContainer>ul>li ul.secondUL');
pending…
Simplified
var el = $('.listContainer .secondUL');
pending…
DataSelect
var el = $('.listContainer ul[data-secondul]');
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