Specific Vs Generic Selectors
JavaScript performance comparison
Info
I was curious how important a very specific selector was when selecting via an attribute with CSS3 selectors.
Preparation code
<input type="text" name="field1" />
<input type="text" name="field2" /><script src="//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
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
jQuery Specific |
|
pending… |
jQuery Generic |
|
pending… |
YUI3 Specific |
|
pending… |
YUI3 Generic |
|
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 Jeff Craig
- Revision 2: published by Jeff Craig
0 comments