jQuery Siblings and decendents

Benchmark created by Mike Cravey on


Description

Testing a few selectors and what is the fastest way to get them

Preparation HTML

<div id="prev">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<p></p>
<div id="next">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
parent > child
$('#prev > div')
ready
parent.find(child)
$('#prev').find('div')
ready
prev + next
$('#prev + div')
ready
prev.next(next)
$('#prev').next('div')
ready
parent:nth-child(3)
$('#prev:nth-child(3)')
ready
parent:gt(2)
$('#prev:gt(2)')
ready
parent:eq(2)
$('#prev:eq(2)')
ready
parent.find(child)[2]
$('#prev').find('div')[2]
ready

Revisions

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

  • Revision 1: published by Mike Cravey on