$.find VS $.children (v2)

Revision 2 of this benchmark created by Jason Feinstein on


Description

Difference between searching for immediate children, all descendants, and the scoping version

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div class="level1">
    <div class="level2">
        <div class="level3">
            <div class="level4">
                <div class="level5" id="foo">
                </div>
                <div class="level5">
                </div>
                <div class="level5">
                </div>
            </div>
        </div>
    </div>
</div>
<script>
  var parentElement = $('.level4');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Immediate children
parentElement.children('.level5');
ready
All descendants
parentElement.find('.level5');
ready
Combined
$('.level5', parentElement);
ready

Revisions

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