Dynamic jQuery element rendering

JavaScript performance comparison

Test case created


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="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
Benchmark.prototype.setup = function() {
    var element = $('#main');

Benchmark.prototype.teardown = function() {

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
n - appends
var i, len;

for(i = 0, len = 1000; i < len; i = i + 1) {
  element.append('<div class="child"></div>');
n - pushs
var arr = [];

for(i = 0, len = 1000; i < len; i = i + 1) {
  arr.push('<div class="child"></div>');


You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers


Comment form temporarily disabled.

Add a comment