YUI.all('div.cl') selector vs YUI.all('.cl') (v17)

Revision 17 of this benchmark created by Rajesh Taneja on


Description

Fastest way get a YUI3 object of a DOM element of which I have the class

Preparation HTML

<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>

Test runner

Ready to run.

Testing in
TestOps/sec
Y.all('div.cl')
Y.all(divc);
ready
Y.all('.cl');
Y.all(c);
ready

Revisions

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