jQuery children() vs has() (v4)

Revision 4 of this benchmark created on


Description

What is fastest, x.children(...).children(...).length, or x.has(...).length.

Preparation HTML

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>

<div id='it'>
<div class='dw-res'>
<div class='dw-i-t'>
</div></div></div>
<script>
  var $it = $('#it');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
childern()
$it.children('.dw-res').children('.dw-i-t').length
ready
has()
$it.has('.dw-res > .dw-i-t').length
 
ready
find()
$it.find('.dw-i-t').length
ready

Revisions

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