Specific Vs Generic Selectors

JavaScript performance comparison

Test case created by Jeff Craig

Preparation code

<input type="text" name="field1" />
<input type="text" name="field2" /><script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/combo?3.2.0/build/yui/yui-min.js&3.2.0/build/oop/oop-min.js&3.2.0/build/dom/dom-min.js&3.2.0/build/dom/dom-style-ie-min.js&3.2.0/build/event-custom/event-custom-base-min.js&3.2.0/build/event/event-base-min.js&3.2.0/build/pluginhost/pluginhost-min.js&3.2.0/build/node/node-min.js&3.2.0/build/event/event-delegate-min.js"></script>
<script>
  Y = YUI().use('node');
</script>
    

Preparation code output

<input type="text" name="field1" /> <input type="text" name="field2" />

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 Specific
$('input[name=field1]');
pending…
jQuery Generic
$('*[name=field1]');
pending…
YUI3 Specific
Y.all('input[name=field1]');
pending…
YUI3 Generic
Y.all('*[name=field1]');
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