What Javascript Template Engines you recommend?

JavascriptTemplate Engine

Javascript Problem Overview


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/

Javascript Solutions


Solution 1 - Javascript

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

Solution 2 - Javascript

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

Solution 3 - Javascript

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 - Javascript

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

Solution 5 - Javascript

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkahaView Question on Stackoverflow
Solution 1 - JavascriptCD..View Answer on Stackoverflow
Solution 2 - JavascriptDaffView Answer on Stackoverflow
Solution 3 - JavascriptVladimir StarkovView Answer on Stackoverflow
Solution 4 - Javascriptpixel 67View Answer on Stackoverflow
Solution 5 - JavascriptmikerobiView Answer on Stackoverflow