performance comparison of jQuery Template vs underscore vs string append vs mustache vs handlebars vs icanhaz vs milk vs swig for table

JavaScript performance comparison

Revision 128 of this test case created

Info

To test performance of jQuery template for outputting 100 rows each with 10 columns where the columns have fields that can trigger events.

Preparation code

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js">
</script>
<script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.js">
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js">
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/mustache.js/0.7.2/mustache.min.js
">

</script>
<script src="//cdn.jsdelivr.net/jsrender/1.0pre35/jsrender.min.js">
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/ICanHaz.js/0.10.3/ICanHaz.min.js
">

</script>
<script src="http://github.com/pvande/Milk/raw/master/dist/v1.2.0/milk.js">
</script>
<script src="//paularmstrong.github.io/swig/js/swig.min.js">
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.min.js" type="text/javascript"></script>
<script type="text/javascript">
  $(function() {
    $('body').delegate('#table .edit a, #table .select a', 'click', function() {
      var $td = $(this).closest('td');
      $td.find('input, select').show();
      $td.find('a').hide();
    });

    $('body').delegate('#table .edit .cancel, $table .select .cancel', 'click', function() {
      var $td = $(this).closest('td');
      $td.find('input, select').hide();
      $td.find('a').show();
    });
  });
</script>
<script type="text/x-jquery-tmpl" id="tmplRow">
  < tr > < td > < input type = "checkbox"
  value = "${id}" / > < /td>
  <td>${firstName} ${lastName}</td > < td class = "edit" > < a > Edit < /a>
    <input style="display:none;" type="hidden" value="Blah" / > < input class = "cancel"
  type = "button"
  value = "cancel" / > < /td>
  <td class="select">
      <a>Select</a > < select style = "display:none;" > < option > 0 < /option>
        <option>1</option > < option > 2 < /option>
        <option>3</option > < option > 4 < /option>
        <option>5</option > < option > 6 < /option>
        <option>7</option > < option > 8 < /option>
        <option>9</option > < option > 10 < /option>
       </select > < input class = "cancel"
  type = "button"
  value = "cancel" / > < /td>
   <td>More string</td > < td > More string < /td>
   <td>More string</td > < td > More string < /td>
   <td>More string</td > < td > More string < /td>
</tr >
</script>
 

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
jQuery templates
var html1 = $("#tmplRow").tmpl(data)
pending…
Precompiled jQuery template
var html3 = $.tmpl("savedTmpl", data);
pending…
Underscore.js
 
pending…
mustache js
 
pending…
ICanHaz.js
 
pending…
Handlebars.js
 
pending…
Milk
 
pending…
swig
 
pending…
handlebars precompiled
 
pending…
underscore precompiled
 
pending…
handlebars2
 
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:

0 comments

Add a comment