Handlebars compile vs precompile (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.rc.1.js"></script>

<!-- template source code -->
<script id="template" type="text/plain">
 <div class="entry">
  <h1>{{title}}</h1>
  <div class="body">
    {{body}}
  </div>
 </div>
</script>

<script>
var tpl = $("#template").html()
eval("var tplfn = " + Handlebars.precompile(tpl))
var pretpl = Handlebars.template(tplfn)
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Precompiled
pretpl({
 title: 'handlebars',
 body: 'teste'
})
ready
Compiled
var template = Handlebars.compile(tpl)
template({
 title: 'handlebars',
 body: 'teste'
})
ready

Revisions

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