jQuery .find() vs descendant selector (v13)

Revision 13 of this benchmark created on


Preparation HTML

<script src = "https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script><div>
<div></div><div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div id="container">
<div></div>
<div></div>
<div class="robotarm"></div>
<div><div class="robotarm"></div></div>
<div class="robotarm"></div>
<div class="robotarm"></div>
<div></div>
</div>
</div>

<div>
<div id="container2">
<div></div>
<div></div>
<div class="robotarm2"></div>
<div><div class="robotarm2"></div></div>
<div class="robotarm2"></div>
<div class="robotarm2"></div>
<div></div>
</div>
</div>
<script>
  var containr = $("#container")[0];
  var container = $("#container");
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Descendant Selector
$('div.robotarm');
ready
Find
$('#container').find('div.robotarm');
ready
Descendant Selector 2
$('#container div.robotarm');
ready
context
$('div.robotarm', container);
ready
context2
$('div.robotarm', containr);
ready
context3
$('div.robotarm', $("#container"));
ready
context4
$('div.robotarm', "#container");
ready

Revisions

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