yet another jQuery selector test

JavaScript performance comparison

Test case created by Scott Kosman

Info

Some more benchmarking tests based on comments at my jQuery Performance article at 24ways.org

http://24ways.org/2011/your-jquery-now-with-less-suck

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<section>
  <div id="content">
    <p>
      foo
    </p>
  </div>
</section>

Preparation code output

foo

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
multi-element
$('body > section div#content p');
pending…
fewer elements in selector
$('#content p');
pending…
complex .find()
$('body > section div#content').find("p");
pending…
simplified .find()
$('#content').find("p");
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:

2 comments

Darren commented :

Many thanks for setting this up Scott. Brilliant! Very enlightening! Off now to rewrite a lot of my code!

Sean commented :

This is great, I didn't know about the right to left parsing. Thanks.

Add a comment