jQuery Selector Perf - Right-to-Left

JavaScript performance comparison

Revision 88 of this test case created by Chris Miller

Info

Demonstrating Right To Left Thinking, and validating its performance.

Preparation code

<div id="parent">
  <p class="child">
    Why Right to Left Thinking is Good
  </p>
  <p class="child">
    Blah Blah Blah
  </p>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>

Preparation code output

Why Right to Left Thinking is Good

Blah Blah Blah

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
"Left to Write" Thinking
$('#parent p');
pending…
"Right To Left" Thinking
$('#parent p.child');
pending…
"Right to Left"
$('#parent').children('p');
pending…
Alternate "Right to Left"
$('#parent').find('p');
pending…
Using child selector
$('#parent > p');
pending…
pure JS
document.getElementById("box").getElementsByTagName("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:

0 comments

Add a comment