direct vs contextual (v5)

Revision 5 of this benchmark created by N2 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<span id="test5"></span></dd>
</dl>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
direct
$("#test5");
ready
complex selector
$(".text4 #test5");
ready
find
$(".text4").find("#test5");
ready
context
$("#test5",$(".text4"));
ready
variable
var context = $(".text4");
$("#test5",context);
ready
comma separated id selector
$("#test1,#test3");
ready
selectors with add()
$("#test1").add("#test3");
ready
find together
$("#test5 .test4");
ready
find separated
$("#test5").find(".text4");
ready
native
document.getElementById('test5');
ready

Revisions

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