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

Revision 9 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 class="foo" id="bogi">
<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!<span class='sp'>test</span></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
classes inside id
$("#bogi .bar")
ready
find classes inside id
$("#bogi").find(".bar")
ready
context with id
$(".bar", "#bogi")
ready
double find
$("#bogi").find(".bar").find(".sp")
ready
one more
$("#bogi").find(".bar .sp")
ready
my code
$("#bogi").find("li.bar")
ready

Revisions

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