full dom vs multipple $.text
JavaScript performance comparison
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="aa">
<div id="a1">0</div>
<div id="a2">0</div>
<div id="a3">0</div>
<div id="a4">0</div>
<div id="a5">0</div>
<div>
<script>
Benchmark.prototype.setup = function() {
var $aa = $('#aa');
var aaHTML = $aa.html()
var $a1 = $('#a1');
var $a2 = $('#a2');
var $a3 = $('#a3');
var $a4 = $('#a4');
var $a5 = $('#a5');
};
</script>
Preparation code output
0
0
0
0
0
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
$.text() |
|
pending… |
full dom |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments