YUI.all('div.cl') selector vs YUI.all('.cl')
JavaScript performance comparison
Info
Fastest way get a YUI3 object of a DOM element of which I have the class
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js">
</script>
<div class="el">
Some HTML element
</div>
<div class="el">
Some HTML element
<div class="el">
Some HTML element
</div>
</div>
<div class="el">
Some HTML element
</div>
<script>
var divc = 'div.el',
c = '.el',
Y;
function S4() {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
}
YUI().use('node', function(Y) {
window.Y = Y
});
</script>
<script>
Benchmark.prototype.setup = function() {
};
</script>
Preparation code output
Some HTML element
Some HTML element
Some HTML element
Some HTML element
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Y.all('div.cl') |
|
pending… |
Y.all('.cl'); |
|
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 streetpc
- Revision 2: published by Hadrien.eu
- Revision 3: published
- Revision 4: published by Hadrien.eu
- Revision 5: published
- Revision 6: published
- Revision 7: published by Devin Rhode
- Revision 8: published
- Revision 9: published
- Revision 10: published
- Revision 11: published
- Revision 12: published
- Revision 13: published
- Revision 14: published
- Revision 15: published
- Revision 16: published
- Revision 17: published by Rajesh Taneja
- Revision 18: published by Abdullah
- Revision 19: published
- Revision 20: published
- Revision 22: published
- Revision 23: published
- Revision 24: published
- Revision 25: published by David S
- Revision 26: published
- Revision 27: published
- Revision 28: published
- Revision 29: published
- Revision 30: published by NJH
0 comments