jquery scoped vs non-scoped
JavaScript performance comparison
Preparation code
<div id="apple">
<div class="red">
Red Apple
</div>
<div class="red big">
Big Red Apple
</div>
<div class="green">
Green Apple
</div>
</div>
<div id="ferrari">
<div class="red">
Red Ferrari
</div>
<div class="red big">
Big Red Ferrari
</div>
<div class="gray">
Gray Ferrari
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
Benchmark.prototype.setup = function() {
var $el = $('#ferrari'),
el = document.getElementById('ferrari'),
$targ = $('.red');
};
</script>
Preparation code output
Red Apple
Big Red Apple
Green Apple
Red Ferrari
Big Red Ferrari
Gray Ferrari
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
scoped |
|
pending… |
parent children |
|
pending… |
parent > child |
|
pending… |
find |
|
pending… |
cached find |
|
pending… |
scoped node |
|
pending… |
cached node: find |
|
pending… |
raw find |
|
pending… |
cached raw: find |
|
pending… |
cached raw: scoped |
|
pending… |
cached scope and target: 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 2: published by dan
0 comments