jQuery nested $(".class") selectors (v7)

Revision 7 of this benchmark created on


Description

Testing whether selecting multiple class names is faster by various methods

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<ul id="foo">
  <li>
    yay!
  </li>
  <li>
    yay!
  </li>
  <li>
    yay!
  </li>
  <li>
    yay!
  </li>
  <li>
    yay!
  </li>
  <li>
    yay!
  </li>
  <li>
    yay!
  </li>
  <li>
    yay!
  </li>
  <li>
    yay!
  </li>
  <li>
    yay!
  </li>
  <li>
    yay!
  </li>
  <li>
    yay!
  </li>
  <li>
    yay!
  </li>
  <li>
    yay!
  </li>
  <li class="bar">
    yay!
  </li>
  <li>
    yay!
  </li>
  <li>
    yay!
  </li>
  <li>
    yay!
  </li>
</ul>

Test runner

Ready to run.

Testing in
TestOps/sec
.find()
$("#foo").find(".bar")
ready
context
$(".bar", "#foo")
ready
multiple classes in one $
$("#foo .bar")
ready
Test
document.getElementsByClassName("bar");
ready
Test2
$(".bar");
ready
Children
$('#foo').children('.bar');
ready

Revisions

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