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

Revision 2 of this benchmark created by vijay 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!</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

Revisions

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