Latest handlebars.js 2.0 and previous versions (v9)

Revision 9 of this benchmark created by msvoren on


Description

Performance comparison between Handlebars 1.2.1, 1.3.0, 2.0

Preparation HTML

<script>
var root = window;
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.2.1/handlebars.min.js"></script>
<script>
var HB121 = Handlebars;
delete window.Handlebars;
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.min.js"></script>
<script>
var HB130 = Handlebars;
delete window.Handlebars;
</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.min.js"></script>
<script>
var HB200_a4 = Handlebars;
delete window.Handlebars;
</script>

Setup

var template = 'Hello {{name}}! You have {{mailCount}} new e-mails. Go back to {{page}} {{#each list}} {{number}} {{/each}} {{#if mailCount}}{{mailCount}}{{/if}}';
    
    var data = {
      name: 'Eneko',
      mailCount: 5,
      page: 'Main page',
      list: []
    };
    
    for (var i = 0; i < 500; i++) {
      data.list.push({
        "number": i
      });
    }
    
    // Precompile
    var compiledHbs121 = HB121.compile(template);
    var compiledHbs130 = HB130.compile(template);
    var compiledHbs200_a4 = HB200_a4.compile(template);

Test runner

Ready to run.

Testing in
TestOps/sec
Handlebars 1.2.1
compiledHbs121(data);
ready
Handlebars 1.3.0
compiledHbs130(data);
ready
Handlebars 2.0.0
compiledHbs200_a4(data);
ready

Revisions

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