I would like to know your opinion about javascript template engine, which one you think is better in terms of performance?
I found some links where people do benchmarking:
http://jsperf.com/jquery-template-table-performance/15
http://jsperf.com/jquery-template-table-performance/8
http://www.viget.com/extend/benchmarking-javascript-templating-libraries/
According to the StackShare community, Pug has a broader approval, being mentioned in 230 company stacks & 608 developers stacks; compared to EJS, which is listed in 9 company stacks and 13 developer stacks.
JavaScript templating engines enable you to add dynamic logic to static HTML pages. For instance, you can declare a variable that the engine replaces with an actual value at runtime. Similarly, you can use conditionals, loops, filters, mixins, and other constructs, depending on the templating engine you choose.
Template-Engine-Chooser! - Tool to help select the right template engine for a project.
In terms of performance I found that it is not the templating engine itself but more if there is the possibility to precompile the templates. It is a good practice to concatenate and minify all your JavaScript source files into one file for production mode anyway, so it is basically the same step to precompile the templates, too.
I've used jQuery template and Mustache for client side templating, but my favorite is still EJS which always peformed a lot faster than anything else I tried so far, especially in production mode (compiles to native string concatenation whenever possible and needs only one DOM access to actually insert the rendered view). It is part of the JavaScriptMVC framework and when using it with StealJS as the dependency manager it does all the template compiling into production for you already (the View Engine also supports Micro, Mustache and jQuery template).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With