jQuery Selector Perf - Right-to-Left

JavaScript performance comparison

Revision 95 of this test case created by Marco Pfeiffer

Info

Demonstrating Right To Left Thinking, and validating its performance for this case.

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"
$('#parent').children('p');
pending…
Alternate "Right to Left"
$('#parent').find('p');
pending…
Using child selector
$('#parent > p');
pending…
pure JS
document.getElementById("parent").getElementsByTagName("p");
pending…
JS kickstarted jQuery
$(document.getElementById("parent").getElementsByTagName("p"));
pending…
Pure JS querySelector
document.querySelector('#parent p');
pending…
Pure JS querySelector children
document.querySelector('#parent > p');
pending…
Pure JS children
document.getElementById("parent").children
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