YUI3 vs. jQuery vs. Sizzle vs. Native selector test (v19)

Revision 19 of this benchmark created by David Calhoun on


Preparation HTML

<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://github.com/jeresig/sizzle/raw/master/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>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery
$('.target-me[name=candy]');
ready
YUI3
Y.all('.target-me[name=candy]');
ready
Sizzle
Sizzle('.target-me[name=candy]');
ready
Native
var elements = document.getElementsByClassName('target-me'),
    i, len, matches = [];

for (i = 0, len = elements.length; i < len; ++i) {
 if (elements[i].getAttribute('name') == 'candy') {
  matches.push(elements[i]);
 }
}
matches;
ready
Native Query Selector
document.querySelectorAll('.target-me[name=candy]');
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.