Comparison betweem logicless js template (v1044)

Revision 1044 of this benchmark created on


Preparation HTML

<script src="http://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>

Test runner

Ready to run.

Testing in
TestOps/sec
Mustache.js
placeholder.empty().html(Mustache.render(window.mustacheTemplate, window.sharedVariables));
ready
Handlebars.js
placeholder.empty().html(Handlebars.compile(window.handlebarsTemplate)(window.sharedVariables));
ready
Dust.js
dust.renderSource(window.dustTemplate, window.sharedVariables, function(err, out) { placeholder.empty().html(out); });
ready
Hogan
placeholder.empty().html(Hogan.compile(window.hoganTemplate).render(window.sharedVariables));
ready
ICanHaz
ich.tt = ich.templates.tt = null; ich.addTemplate('tt', window.ichTemplate); placeholder.empty().html(ich.tt(window.sharedVariables));
ready
Markup
placeholder.empty().html(Mark.up(window.markupTemplate, window.sharedVariables));
ready
Mustache.js Preparse
placeholder.empty().html(Mustache.render(window.mustacheTemplatePreparse, window.sharedVariables));
ready
Handlebars.js Precompile
placeholder.empty().html(handlebarsTemplatePrecompile(window.sharedVariables));
ready
Dust.js Precompile
dust.render('dustTemplatePrecompile', window.sharedVariables, function(err, out) { placeholder.empty().html(out); });
ready
Hogan Precompile
placeholder.empty().html(hoganTemplatePrecompile.render(window.sharedVariables));
ready
ICanHaz Precompile
placeholder.empty().html(ich.ichTemplatePrecompile(window.sharedVariables));
ready
doT (logic) - Precompile
placeholder.empty().html(window.doTTemplatePrecompile(window.sharedVariables));
ready

Revisions

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