jQuery vs Sizzle vs Midori vs YUI vs Peppy vs Dojo vs XUI vs QuerySelectorAll - selectors test

JavaScript performance comparison

Revision 26 of this test case created by Addy Osmani

Preparation code

<script src="https://xui-js.googlecode.com/files/xui-core-1.0.0.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js"></script>
<script src="https://jamesdonaghue.com/static/peppy/peppy-min.js"></script>
<script src="https://www.midorijs.com/midori.js"></script>
<script src="https://yui.yahooapis.com/3.2.0/build/yui/yui-min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script>var j4 = jQuery.noConflict();</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2/jquery.min.js"></script>
<script>var j2 = jQuery.noConflict();</script>
<script src="https://linkedin.com/lib/sizzle/1.0/sizzle.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>var j62 = jQuery.noConflict();</script>

<div id="test"> 
        <div class="testlink">
                <a href="#" id="linkone" title="test">test link</a>
        </div> 
        <div class="testmenu">
                <ul>
                        <li class="menuitem itemone">
                                <a href="#" title="item 1">menu item 1</a>
                        </li>
                        <li class="menuitem itemtwo">
                                <a href="#" title="item 2">menu item 2</a>
                        </li>
                        <li class="menuitem itemthree">
                                not clickable item 3
                        </li>
                </ul>
        </div>
</div>
<script>
  var selectors = ['body', 'div', 'body div', 'div a', 'div > a', 'div[class^=test]', 'div, li, a', '.menuitem', 'li.menuitem', '#linkone', 'div#test', 'a[title*=item]', 'a[title=test]', 'li:nth-child(even)', 'li:nth-child(odd)', 'li:last-child', 'li:first-child'];
  
  var Y = YUI().use('node');
  
  dojo.require('dojo.query');
</script>
    

Preparation code output

<div id="test"> <div class="testlink"> <a href="#" id="linkone" title="test">test link</a> </div> <div class="testmenu"> <ul> <li class="menuitem itemone"> <a href="#" title="item 1">menu item 1</a> </li> <li class="menuitem itemtwo"> <a href="#" title="item 2">menu item 2</a> </li> <li class="menuitem itemthree"> not clickable item 3 </li> </ul> </div> </div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
jQuery 1.4 (with Sizzle)
for (var sel in selectors) {
 j4(selectors[sel]);
}
pending…
jQuery 1.2 (no Sizzle)
for (var sel in selectors) {
 j2(selectors[sel]);
}
pending…
Sizzle
for (var sel in selectors) {
 Sizzle(selectors[sel]);
}
pending…
Midori
for (var sel in selectors) {
 midori.get(selectors[sel]);
}
pending…
YUI3
for (var sel in selectors) {
 Y.one(selectors[sel]);
}
pending…
Peppy
for (var sel in selectors) {
 peppy.query(selectors[sel]);
}
pending…
Dojo
for (var sel in selectors) {
 dojo.query(selectors[sel]);
}
pending…
XUI
for (var sel in selectors) {
 x$(selectors[sel]);
}
pending…
querySelectorAll
for (var sel in selectors) {
 document.querySelectorAll(selectors[sel]);
}
pending…
YUI3 .all()
for (var sel in selectors) {
 Y.all(selectors[sel]);
}
pending…
querySelector
for (var sel in selectors) {
 document.querySelector(selectors[sel]);
}
pending…
jQuery 1.6.2
for (var sel in selectors) {
 j62(selectors[sel]);
}
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.

0 Comments