Delegate Document vs Element
JavaScript performance comparison
Preparation code
<div id="test-parent1" class="test-parent">
<div id="test-child1" class="test-child">
<div class="test-grandchild"></div>
</div>
<div id="test-child2" class="test-child"></div>
<div id="test-child3" class="test-child"></div>
<div id="test-child3" class="test-child"></div>
</div>
<div id="test-parent2" class="test-parent">
<div id="test-child1" class="test-child">
<div class="test-grandchild"></div>
</div>
<div id="test-child2" class="test-child"></div>
<div id="test-child3" class="test-child"></div>
<div id="test-child3" class="test-child"></div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
Benchmark.prototype.setup = function() {
var $testParent = $('#test-parent1')
$testParents = $('.test-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 | |
|---|---|---|
Delegate Document |
|
pending… |
Delegate Element |
|
pending… |
Delegate Element Cached |
|
pending… |
Delegate Elements |
|
pending… |
Delegate Elements Cached |
|
pending… |
Document Multi Delegate |
|
pending… |
Element Multi Delegate |
|
pending… |
Document Elements Delegate |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments