YUI3 vs. jQuery vs. Sizzle vs. Native selector test

JavaScript performance comparison

Revision 15 of this test case created by Ryan Grove

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://yui.yahooapis.com/3.2.0pr1/build/yui/yui-min.js"></script>
<script src="http://www.linkedin.com/lib/sizzle/1.0/sizzle.js"></script>

<section class="target-me" name="donuts">.target-me</section>
<section class="target-me">.target-me</section>
<section class="target-me" name="candy">.target-me</section>
<script>
  Y = YUI().use('node');
</script>

Preparation code output

.target-me
.target-me
.target-me

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
jQuery
$('.target-me[name=candy]');
pending…
YUI3
Y.all('.target-me[name=candy]');
pending…
Sizzle
Sizzle('.target-me[name=candy]');
pending…
Native
var elements = document.getElementsByClassName('target-me'),
    i, len;

for (i = 0, len = elements.length; i < len; ++i) {
  if (elements[i].getAttribute('name') == 'candy') {
    break;
  }
}
pending…
Native Query Selector
document.querySelectorAll('.target-me[name=candy]');
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