What Javascript Template Engines you recommend? [closed]

What Javascript Template Engines you recommend? [closed]

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/

Solutions/Answers:

Solution 1:

Template-Engine-Chooser! – Tool to help select the right template engine for a project.

Solution 2:

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).

Related:  ES6+ javascript module export options

Solution 3:

May be PURE — it allows to transform JSON into HTML with templates made from your existed html, not from separate template with special syntax.

From the PURE’s site:

Simple and ultra-fast templating tool
to generate HTML from JSON data

The representation (HTML) and the logic (JS)
remain totally separated

Works standalone or with dojo, DomAssistant, Ext JS,
jQuery, Mootools, Prototype, Sizzle and Sly

The best way to understand is to see what this library actually do: (from official demo)
pure template engine demonstration

All the demos are here

Solution 4:

LinkedIn went with dust.js
http://akdubya.github.com/dustjs/

Solution 5:

Pick the template language that has an api and syntax you find most appealing. If you run in to performance problems, then you can look at alternatives.

Unless you are constructing tables with thousands of rows, you probably won’t notice a difference.

Personally I use Google’s Closure Templates. I chose it mainly because it also has a Java implementation. I have never done benchmarks.

Related:  Get the Size of a CSS Background Image Using JavaScript?