jQuery find vs context selector (v10)

Revision 10 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<div id="test1">
<dl>
<dt>Hi</dt>
<dd>There</dd>
</dl>
</div>

<div class="test2">
<dl><dt>Hi</dt>
<dd>There</dd>
</dl>
</div>

<div id="test3">
<dl>
<dt class="test3a">Hi</dt>
<dd class="test3b">There</dd></dl>
</div>

<div class="test4">
<dl>
<dt class="test4a">Hi</dt>
<dd class="test4b">There</dd>
</dl>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
find (subset of id)
$("#test1").find("dt, dd");
ready
context (subset of id)
$("#test1 dd,dt");
ready
find (subset of class)
$(".test2").find("dt, dd");
ready
context (subset of class)
$("dt, dd", $(".test2"));
ready
find class (subset of id)
$("#test3").find(".test3a, .test3b");
ready
context class (subset of id)
$(".test3a, .test3b", $("#test3"));
ready
find class (subset of class)
$(".test4").find(".test4a, .test4b");
ready
context class (subset of class)
$(".test4a, .test4b", $(".test4"));
ready

Revisions

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