.find() Versus Selectors
JavaScript performance comparison
Info
Will the battle never end?
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="null">
</div>
<div id="a">
<div class="null">
</div>
<div class="null">
</div>
<div class="null">
</div>
<div class="a">
<div class="c">
<div class="null">
</div>
<div class="b">
</div>
<div class="null">
</div>
</div>
<div class="null">
</div>
</div>
</div>
<script>
Benchmark.prototype.setup = function() {
var $a = $('#a');
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Selector |
|
pending… |
Context |
|
pending… |
.find() |
|
pending… |
Cached .find() |
|
pending… |
Cached Context |
|
pending… |
Speed .find() |
|
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 Vaughn
- Revision 2: published
- Revision 3: published
- Revision 4: published
- Revision 5: published
- Revision 7: published by Vaughn
- Revision 9: published by Vaughn
- Revision 10: published
0 comments