Handlebars compile vs precompile (v7)

Revision 7 of this benchmark created by Samuel on


Description

No longer on Doc Ready, no longer wrapped in a complete <html> document.

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.min.js"></script>
<script id="example" type="text/x-handlebars-template"><div> {{ exampleText }} </div></script>

Setup

var context = { exampleText: 'test' };
    
    (function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t["example"]=e(function(e,t,n,r,i){this.compilerInfo=[4,">= 1.0.0"];n=this.merge(n,e.helpers);i=i||{};var s="",o,u="function",a=this.escapeExpression;s+="<div> ";if(o=n.exampleText){o=o.call(t,{hash:{},data:i})}else{o=t.exampleText;o=typeof o===u?o.apply(t):o}s+=a(o)+" </div>";return s})})();

Test runner

Ready to run.

Testing in
TestOps/sec
Normal Compilation
var theTemplate = Handlebars.compile($("#example").html());
theTemplate(context);
ready
Precomp
Handlebars.templates.example(context);
ready

Revisions

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