Dynamic jQuery element rendering
JavaScript performance comparison
Info
Tests the performance of calling jQuery.append() n times vs the performance of pushing n elements to an array and calling jQuery.html(arr.join('')).
Preparation code
<div id="main"></div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script>
Benchmark.prototype.setup = function() {
var element = $('#main');
};
Benchmark.prototype.teardown = function() {
$('#main').empty();
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
n - appends |
|
pending… |
n - pushs |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments