Descendent Selector vs Find From Parent
JavaScript performance comparison
Info
A comparison between using a descendant selector $('.level-one .some-child') vs using find $('.level-one').find('.some-child').
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div></div>
<table class="level-one">
<tr>
<td class="some-child"></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td class="some-child"></td>
</tr>
</table>
<div></div>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Descendant Selector |
|
pending… |
Descendant Selector Strong Left |
|
pending… |
Descendant Selector Strong Right |
|
pending… |
Descendant Selector Strong Both |
|
pending… |
Find |
|
pending… |
Find Strong Parent |
|
pending… |
Find Strong Child |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by Tyler Wood
- Revision 2: published
- Revision 3: published by Tyler Wood
0 comments