$.find VS $.children (v9)

Revision 9 of this benchmark created on


Description

Difference between searching for immediate children instead of all descendants

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
Immediate children via find
parentElement.find('>.level5');
ready

Revisions

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