Comparison betweem logicless js template

JavaScript performance comparison

Revision 1044 of this test case created by

Preparation code

<script src="https://code.jquery.com/jquery-2.1.3.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/mustache.js/0.8.1/mustache.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/3.0.2/handlebars.min.js"></script>
<script type="text/javascript" src="http://cdn.rawgit.com/linkedin/dustjs/master/dist/dust-full.min.js"></script>
<script type="text/javascript" src="http://twitter.github.com/hogan.js/builds/3.0.1/hogan-3.0.1.js"></script>
<script type="text/javascript" src="http://cdn.rawgit.com/HenrikJoreteg/ICanHaz.js/master/ICanHaz.min.js"></script>
<script type="text/javascript" src="http://cdn.rawgit.com/adammark/Markup.js/master/src/markup.min.js"></script>
<script type="text/javascript" src="http://cdn.rawgit.com/olado/doT/master/doT.min.js"></script>


<script>
    window.sharedVariables = {
        header: "Header",
        a: 'aaa',
        b: 'bbb',
        c: 'ccc',
        d: 'ddd',
        e: 'eee',
        f: 'fff',
        obj: {
            A: 'AAA',
            B: 'BBB'
        },
        arr: [
            'arrA',
            'arrB',
            'arrC'
        ],
        fn: function () {
            return 'fnfn';
        }
    };

    window.mustacheTemplate = 
        "<div>" + 
            "<h1 class='header'>{{header}}</h1><div class='a'>{{a}}</div><div class='b'>{{b}}<div class='c'>{{c}}<div class='d'>{{d}}<div class='e'>{{e}}<div class='f'>{{f}}</div></div></div></div></div>" +
            "<div class='obj'>{{obj.A}} {{obj.B}}</div>" +
            "<div class='arr'>{{arr}}</div>" +
            "<div class='fn'>{{fn}}</div>" +
        "</div>";
        
    window.mustacheTemplatePreparse = 
        "<div>" + 
            "<h1 class='header'>{{header}}</h1><div class='a'>{{a}}</div><div class='b'>{{b}}<div class='c'>{{c}}<div class='d'>{{d}}<div class='e'>{{e}}<div class='f'>{{f}}</div></div></div></div></div>" +
            "<div class='obj'>{{obj.A}} {{obj.B}}</div>" +
            "<div class='arr'>{{arr}}</div>" +
            "<div class='fn'>{{fn}}</div>" +
        "</div>";
    Mustache.parse(window.mustacheTemplatePreparse);
        
    window.handlebarsTemplate = 
        "<div>" + 
            "<h1 class='header'>{{header}}</h1><div class='a'>{{a}}</div><div class='b'>{{b}}<div class='c'>{{c}}<div class='d'>{{d}}<div class='e'>{{e}}<div class='f'>{{f}}</div></div></div></div></div>" +
            "<div class='obj'>{{obj.A}} {{obj.B}}</div>" +
            "<div class='arr'>{{arr}}</div>" +
            "<div class='fn'>{{fn}}</div>" +
        "</div>";
        
    window.handlebarsTemplatePrecompile = Handlebars.compile(window.handlebarsTemplate);
    
    window.dustTemplate = 
        "<div>" + 
            "<h1 class='header'>{header}</h1><div class='a'>{a}</div><div class='b'>{b}<div class='c'>{c}<div class='d'>{d}<div class='e'>{e}<div class='f'>{f}</div></div></div></div></div>" +
            "<div class='obj'>{obj.A} {obj.B}</div>" +
            "<div class='arr'>{arr}</div>" +
            "<div class='fn'>{fn}</div>" +
        "</div>";
    
    dust.loadSource(dust.compile(window.dustTemplate, 'dustTemplatePrecompile'));
        
    window.hoganTemplate = 
        "<div>" + 
            "<h1 class='header'>{{header}}</h1><div class='a'>{{a}}</div><div class='b'>{{b}}<div class='c'>{{c}}<div class='d'>{{d}}<div class='e'>{{e}}<div class='f'>{{f}}</div></div></div></div></div>" +
            "<div class='obj'>{{obj.A}} {{obj.B}}</div>" +
            "<div class='arr'>{{arr}}</div>" +
            "<div class='fn'>{{fn}}</div>" +
        "</div>";
        
    window.hoganTemplatePrecompile = Hogan.compile(window.hoganTemplate);
    
    window.ichTemplate = 
        "<div>" + 
            "<h1 class='header'>{{header}}</h1><div class='a'>{{a}}</div><div class='b'>{{b}}<div class='c'>{{c}}<div class='d'>{{d}}<div class='e'>{{e}}<div class='f'>{{f}}</div></div></div></div></div>" +
            "<div class='obj'>{{obj.A}} {{obj.B}}</div>" +
            "<div class='arr'>{{arr}}</div>" +
            "<div class='fn'>{{fn}}</div>" +
        "</div>";
        
    ich.addTemplate('ichTemplatePrecompile', window.ichTemplate);
        
    window.markupTemplate = 
        "<div>" + 
            "<h1 class='header'>{{header}}</h1><div class='a'>{{a}}</div><div class='b'>{{b}}<div class='c'>{{c}}<div class='d'>{{d}}<div class='e'>{{e}}<div class='f'>{{f}}</div></div></div></div></div>" +
            "<div class='obj'>{{obj.A}} {{obj.B}}</div>" +
            "<div class='arr'>{{arr}}</div>" +
            "<div class='fn'>{{fn}}</div>" +
        "</div>";
        
    window.doTTemplate = 
        "<div>" + 
            "<h1 class='header'>{{=it.header}}</h1><div class='a'>{{=it.a}}</div><div class='b'>{{=it.b}}<div class='c'>{{=it.c}}<div class='d'>{{=it.d}}<div class='e'>{{=it.e}}<div class='f'>{{=it.f}}</div></div></div></div></div>" +
            "<div class='obj'>{{=it.obj.A}} {{=it.obj.B}}</div>" +
            "<div class='arr'>{{~it.arr :value}}{{=value}}{{~}}</div>" +
            "<div class='fn'>{{=it.fn()}}</div>" +
        "</div>";
        
    window.doTTemplatePrecompile = doT.compile(window.doTTemplate);
    
    $(function () {
        window.placeholder = $('#placeholder');
    });
</script>
<div id="placeholder"></div>
    

Preparation code output

<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/mustache.js/0.8.1/mustache.min.js"></script> <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/3.0.2/handlebars.min.js"></script> <script type="text/javascript" src="http://cdn.rawgit.com/linkedin/dustjs/master/dist/dust-full.min.js"></script> <script type="text/javascript" src="http://twitter.github.com/hogan.js/builds/3.0.1/hogan-3.0.1.js"></script> <script type="text/javascript" src="http://cdn.rawgit.com/HenrikJoreteg/ICanHaz.js/master/ICanHaz.min.js"></script> <script type="text/javascript" src="http://cdn.rawgit.com/adammark/Markup.js/master/src/markup.min.js"></script> <script type="text/javascript" src="http://cdn.rawgit.com/olado/doT/master/doT.min.js"></script> <script> window.sharedVariables = { header: "Header", a: 'aaa', b: 'bbb', c: 'ccc', d: 'ddd', e: 'eee', f: 'fff', obj: { A: 'AAA', B: 'BBB' }, arr: [ 'arrA', 'arrB', 'arrC' ], fn: function () { return 'fnfn'; } }; window.mustacheTemplate = "<div>" + "<h1 class='header'>{{header}}</h1><div class='a'>{{a}}</div><div class='b'>{{b}}<div class='c'>{{c}}<div class='d'>{{d}}<div class='e'>{{e}}<div class='f'>{{f}}</div></div></div></div></div>" + "<div class='obj'>{{obj.A}} {{obj.B}}</div>" + "<div class='arr'>{{arr}}</div>" + "<div class='fn'>{{fn}}</div>" + "</div>"; window.mustacheTemplatePreparse = "<div>" + "<h1 class='header'>{{header}}</h1><div class='a'>{{a}}</div><div class='b'>{{b}}<div class='c'>{{c}}<div class='d'>{{d}}<div class='e'>{{e}}<div class='f'>{{f}}</div></div></div></div></div>" + "<div class='obj'>{{obj.A}} {{obj.B}}</div>" + "<div class='arr'>{{arr}}</div>" + "<div class='fn'>{{fn}}</div>" + "</div>"; Mustache.parse(window.mustacheTemplatePreparse); window.handlebarsTemplate = "<div>" + "<h1 class='header'>{{header}}</h1><div class='a'>{{a}}</div><div class='b'>{{b}}<div class='c'>{{c}}<div class='d'>{{d}}<div class='e'>{{e}}<div class='f'>{{f}}</div></div></div></div></div>" + "<div class='obj'>{{obj.A}} {{obj.B}}</div>" + "<div class='arr'>{{arr}}</div>" + "<div class='fn'>{{fn}}</div>" + "</div>"; window.handlebarsTemplatePrecompile = Handlebars.compile(window.handlebarsTemplate); window.dustTemplate = "<div>" + "<h1 class='header'>{header}</h1><div class='a'>{a}</div><div class='b'>{b}<div class='c'>{c}<div class='d'>{d}<div class='e'>{e}<div class='f'>{f}</div></div></div></div></div>" + "<div class='obj'>{obj.A} {obj.B}</div>" + "<div class='arr'>{arr}</div>" + "<div class='fn'>{fn}</div>" + "</div>"; dust.loadSource(dust.compile(window.dustTemplate, 'dustTemplatePrecompile')); window.hoganTemplate = "<div>" + "<h1 class='header'>{{header}}</h1><div class='a'>{{a}}</div><div class='b'>{{b}}<div class='c'>{{c}}<div class='d'>{{d}}<div class='e'>{{e}}<div class='f'>{{f}}</div></div></div></div></div>" + "<div class='obj'>{{obj.A}} {{obj.B}}</div>" + "<div class='arr'>{{arr}}</div>" + "<div class='fn'>{{fn}}</div>" + "</div>"; window.hoganTemplatePrecompile = Hogan.compile(window.hoganTemplate); window.ichTemplate = "<div>" + "<h1 class='header'>{{header}}</h1><div class='a'>{{a}}</div><div class='b'>{{b}}<div class='c'>{{c}}<div class='d'>{{d}}<div class='e'>{{e}}<div class='f'>{{f}}</div></div></div></div></div>" + "<div class='obj'>{{obj.A}} {{obj.B}}</div>" + "<div class='arr'>{{arr}}</div>" + "<div class='fn'>{{fn}}</div>" + "</div>"; ich.addTemplate('ichTemplatePrecompile', window.ichTemplate); window.markupTemplate = "<div>" + "<h1 class='header'>{{header}}</h1><div class='a'>{{a}}</div><div class='b'>{{b}}<div class='c'>{{c}}<div class='d'>{{d}}<div class='e'>{{e}}<div class='f'>{{f}}</div></div></div></div></div>" + "<div class='obj'>{{obj.A}} {{obj.B}}</div>" + "<div class='arr'>{{arr}}</div>" + "<div class='fn'>{{fn}}</div>" + "</div>"; window.doTTemplate = "<div>" + "<h1 class='header'>{{=it.header}}</h1><div class='a'>{{=it.a}}</div><div class='b'>{{=it.b}}<div class='c'>{{=it.c}}<div class='d'>{{=it.d}}<div class='e'>{{=it.e}}<div class='f'>{{=it.f}}</div></div></div></div></div>" + "<div class='obj'>{{=it.obj.A}} {{=it.obj.B}}</div>" + "<div class='arr'>{{~it.arr :value}}{{=value}}{{~}}</div>" + "<div class='fn'>{{=it.fn()}}</div>" + "</div>"; window.doTTemplatePrecompile = doT.compile(window.doTTemplate); $(function () { window.placeholder = $('#placeholder'); }); </script> <div id="placeholder"></div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Mustache.js
placeholder.empty().html(Mustache.render(window.mustacheTemplate, window.sharedVariables));
pending…
Handlebars.js
placeholder.empty().html(Handlebars.compile(window.handlebarsTemplate)(window.sharedVariables));
pending…
Dust.js
dust.renderSource(window.dustTemplate, window.sharedVariables, function(err, out) { placeholder.empty().html(out); });
pending…
Hogan
placeholder.empty().html(Hogan.compile(window.hoganTemplate).render(window.sharedVariables));
pending…
ICanHaz
ich.tt = ich.templates.tt = null; ich.addTemplate('tt', window.ichTemplate); placeholder.empty().html(ich.tt(window.sharedVariables));
pending…
Markup
placeholder.empty().html(Mark.up(window.markupTemplate, window.sharedVariables));
pending…
Mustache.js Preparse
placeholder.empty().html(Mustache.render(window.mustacheTemplatePreparse, window.sharedVariables));
pending…
Handlebars.js Precompile
placeholder.empty().html(handlebarsTemplatePrecompile(window.sharedVariables));
pending…
Dust.js Precompile
dust.render('dustTemplatePrecompile', window.sharedVariables, function(err, out) { placeholder.empty().html(out); });
pending…
Hogan Precompile
placeholder.empty().html(hoganTemplatePrecompile.render(window.sharedVariables));
pending…
ICanHaz Precompile
placeholder.empty().html(ich.ichTemplatePrecompile(window.sharedVariables));
pending…
doT (logic) - Precompile
placeholder.empty().html(window.doTTemplatePrecompile(window.sharedVariables));
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.

0 Comments