After reading What are the differences between Mustache.js and Handlebars.js? I was puzzled with a question:
What does pre-compiling of javascript templates means?
Previously I was using a simple client-side caching, which was working something like this:
var tmpCache = {};
if (tmpIneed is in tmpCache){
use it
} else {
take it from DOM / upload from external file
put save it in tmpCache
use it
}
How is this fundamentally different from my technique?
Since Handlebars.js can have different expression/rendering logic in the template, these expressions are typically processed during runtime. For better performance and smaller dependency, the templates can be pre-compiled before deployment. For example, here is a simple handlebar template:
And here is the pre-compiled output
More info about pre-compiling can be found here