jQuery Selector Perf - Right-to-Left
JavaScript performance comparison
Preparation code
<div id="box">
<p> Hi </p>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
Preparation code output
Hi
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
"Left to Write" Thinking |
|
pending… |
"Right to Left" |
|
pending… |
Alternate "Right to Left" |
|
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:
- Revision 1: published by Jeffrey Way
- Revision 32: published
- Revision 37: published
- Revision 38: published
- Revision 40: published
- Revision 41: published
- Revision 44: published
- Revision 45: published
- Revision 46: published
- Revision 47: published
- Revision 48: published
- Revision 49: published
- Revision 50: published by ShiningRay
- Revision 52: published
- Revision 54: published
- Revision 55: published by tick
- Revision 56: published
- Revision 57: published
- Revision 58: published by MoonScript
- Revision 59: published by richard
- Revision 60: published
- Revision 61: published
- Revision 62: published
- Revision 63: published
- Revision 64: published
- Revision 65: published
- Revision 68: published by m--s
- Revision 69: published by devu
- Revision 70: published by Scott Kosman
- Revision 71: published
- Revision 74: published
- Revision 75: published
- Revision 83: published
- Revision 84: published
- Revision 87: published
- Revision 88: published by Chris Miller
- Revision 89: published by Chris Miller
- Revision 90: published by Chris Miller
- Revision 91: published
- Revision 92: published by Dominik Nejdl
- Revision 93: published
- Revision 94: published
- Revision 95: published by Marco Pfeiffer
- Revision 97: published
- Revision 98: published
- Revision 99: published
- Revision 101: published
- Revision 102: published
- Revision 103: published
- Revision 104: published by BinaryKitten
- Revision 105: published
- Revision 106: published by Reith
- Revision 107: published
- Revision 108: published
- Revision 109: published
- Revision 110: published
- Revision 112: published by Claire
- Revision 113: published by Claire Martinez
- Revision 114: published
- Revision 115: published
10 comments
Jeffery, sometimes you amaze me.
The numbers for Opera are vastly different than firefox. And also the speed of reading is reversed. why is that?
You should note that
$('#box').children('p');is equivalent to$('#box > p'), not$('#box p'). You’re comparing snippets that perform different tasks.I think you meant "Left to right" and not "Left to write"?
Very interesting!
Have added a few additional tests under rev 32. This whole test is incredibly relevant, we've been discussing it at work lots recently.
jQuery ultimately boils most things like this down to find where possible, so that's going to usually be the best approach.
I tested in Opera 11.01, IE 8.0 , Chrome 9.0.597.98, Safari 5.0.3 and Firefox 3.6.13. The results are showing same way except Opera.
Very interesting! I new in jquery it is good to know what is the fastest way to search tags :) .
Thanks again
http://jsperf.com/predefined-vs-new-query/2
check that out.. (note the bottom 2 examples)
check that out (bottom)... http://jsperf.com/jquery-selector-perf-right-to-left/59
makes you wonder about how your user experience is affected.
Great. I wish we could have a place to include all of these tips and tricks related to jQuery.