I recently changed our asp.net gridviews (which worked with update panels) to HTML tables, using jquery-Ajax and templating using jtemplates. The performance improvement was huge!!! (on the server side I am using a generic httphandler). One performance problem I am dealing with occurs on Firefox, because of the jtemplate plugin. Somehow it takes F.F to render a 20 rows template up to 3 seconds!!! (on I.E or chrome it takes about 100ms). Which is the preferred templating plugin, when my goal is mainly simplicity and performance? I am trying jsrender, which is fast, but not documented enough(I had some problems doing things inside a for loop). Knockoutjs seems great but is pretty sofisticated and I am afraid of performance problems as well. Thanks!!!
Asked
Active
Viewed 2,141 times
3
-
1I like underscore.js's template function. http://documentcloud.github.com/underscore/#template – asawyer Apr 11 '12 at 18:37
1 Answers
6
Fore pure templating, JsRender is awesome. JsRender is really fast. Check out the perf page here: http://jsperf.com/dom-vs-innerhtml-based-templating/395
It compares the various templating engines rendering data, and JsRender fared very well on all browsers. JsRender has no DOM dependency, no jQuery dependency (though you can certainly use it with it ... I do) and is pure string based rendering.
if you go that route, here is an article I wrote on getting started: http://jpapa.me/clientIn1204
If you wanted more of a framework for data binding that has templates, Knockout would be excellent. But for pure perf, JsRender is a great choice.

John Papa
- 21,880
- 4
- 61
- 60
-
Thanks! I read your article from MSDN, loved it... I think I would stay with JSRender. My only problem was accessing class properties from inside a for loop (the for loop iterates a list of objects and I wanted to access a property of the main data class – Yaniv Efraim Apr 12 '12 at 05:43
-
1Thanks. You can access the parent context inside the loop by doing #parent.parent.data.someProperty (or similar object dot syntax). – John Papa Apr 12 '12 at 21:24