jQuery .find() vs. context selector vs non-context selector
JavaScript performance comparison
Info
comparing selector speed
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<p>
<ins>
</ins>
</p>
<article>
<p>
A test
</p>
<p>
<ins>
</ins>
</p>
<p>
This is text
</p>
</article>
<p>
<ins>
</ins>
</p>
<article>
<p>
A test
</p>
<p>
<ins>
</ins>
</p>
<p>
This is text
</p>
</article>
<p>
<ins>
</ins>
</p>
<article>
<p>
A test
</p>
<p>
<ins>
</ins>
</p>
<p>
This is text
</p>
<article>
<p>
A test
</p>
<p>
<ins>
</ins>
</p>
<p>
This is text
</p>
<article>
<p>
A test
</p>
<p>
<ins>
</ins>
</p>
<p>
This is text
</p>
<article>
<p>
A test
</p>
<p>
<ins>
</ins>
</p>
<p>
This is text
</p>
<article>
<p>
A test
</p>
<p>
<ins>
</ins>
</p>
<p>
This is text
</p>
<article>
<p>
A test
</p>
<p>
<ins>
</ins>
</p>
<p>
This is text
</p>
<article>
<p>
A test
</p>
<p>
<ins>
</ins>
</p>
<p>
This is text
</p>
</article>
</article>
</article>
</article>
</article>
</article>
</article>
<article>
<p>
A test
</p>
<div>
<div>
<div>
<p>
<ins>
</ins>
</p>
</div>
</div>
</div>
<p>
This is text
</p>
</article>
<script>
Benchmark.prototype.setup = function() {
var $article = $('article');
var article = $article[0];
};
</script>
Preparation code output
A test
This is text
A test
This is text
A test
This is text
A test
This is text
A test
This is text
A test
This is text
A test
This is text
A test
This is text
A test
This is text
A test
This is text
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
find method (node context) |
|
pending… |
find method (jquery context) |
|
pending… |
context node |
|
pending… |
context jQuery |
|
pending… |
context jQuery[0] |
|
pending… |
cascade |
|
pending… |
context (no cached) |
|
pending… |
find method (no cached) |
|
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 Brian
- Revision 2: published
- Revision 3: published
- Revision 4: published
- Revision 5: published by jhongomz
- Revision 6: published by mekwall
- Revision 7: published
- Revision 8: published
- Revision 9: published
- Revision 10: published
- Revision 11: published by Mike Chu
- Revision 12: published by James Fuller
- Revision 13: published by RubaXa
- Revision 14: published
- Revision 15: published by dw
- Revision 16: published
- Revision 17: published by harry
- Revision 18: published
- Revision 19: published
- Revision 20: published
- Revision 21: published by Chris
- Revision 22: published
- Revision 23: published
- Revision 24: published
- Revision 25: published by tiffon
- Revision 26: published by Cory
- Revision 27: published
- Revision 28: published by Cory
- Revision 29: published
- Revision 30: published
- Revision 31: published
- Revision 32: published
- Revision 33: published
- Revision 34: published
- Revision 36: published by Caleb Gilbert
- Revision 37: published
- Revision 38: published by Albert Casademont
- Revision 39: published
0 comments