jQuery Selector Benchmark
JavaScript performance comparison
Info
You can select children on a DOM in so many ways. This test breaks down selecting children in a list with use of a context, no context, and child selectors.
Preparation code
<script src="//code.jquery.com/jquery-1.8.3.min.js">
</script>
<div id="container">
<ul id="parent">
<li class="child">
</li>
<li class="foo">
</li>
<li class="child">
</li>
<li class="bar">
</li>
</ul>
</div>
<script>
Benchmark.prototype.setup = function() {
//Save The Context
var parentContext = document.getElementById('parent');
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Context |
|
pending… |
Find |
|
pending… |
Alternate Find |
|
pending… |
Children |
|
pending… |
Parent / Child Selector |
|
pending… |
Class Only |
|
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 Chris Miller
- Revision 2: published
- Revision 3: published by Chris Miller
- Revision 4: published
- Revision 5: published
- Revision 6: published
- Revision 7: published
- Revision 8: published
- Revision 9: published
- Revision 10: published
- Revision 11: published
- Revision 12: published
- Revision 13: published
- Revision 14: published
- Revision 15: published
- Revision 16: published
- Revision 17: published
- Revision 18: published
- Revision 19: published
- Revision 21: published
0 comments