3 ms·
Client-side templating has its place when used with proper progressive enhancement. That said, if your template rendering is what's bogging your server(s) down,
by spjwebster 15y ago
Client-side templating has its place when used with proper progressive enhancement. That said, if your template rendering is what's bogging your server(s) down, you really need to reevaluate your choice of template engine.
The problem with relying on the client to handle templating is one of robustness. JavaScript is an extremely fragile runtime, and one JavaScript error in a piece of third-party ad or widget code can prevent any other JavaScript on the page from executing. If you're relying on JavaScript to render your website, that means a bit fat empty page for your users. It happens: http://isolani.co.uk/blog/javascript/BreakingTheWebWithHashBangs http://isolani.co.uk/blog/javascript/BreakingTheWebWithHashB...
You're effectively offloading a critical part of your application to a runtime environment that you do not control and that third party code can break at a whim. I don't know about you, but that would scare the bejesus out of me.
Me? I prefer server-side rendering, with progressively-enhanced client-side rendering where it makes sense (e.g. an AJAX-powered infinite carousel).
- spjwebster 15y agoAlso, you need to be really careful about memory leaks when replacing the DOM wholesale as you recommend in http://blog.rassemblr.com/2011/05/on-client-side-templating-part-ii-mustache-json-jquery-and-some-fun/ http://blog.rassemblr.com/2011/05/on-client-side-templating-... Any references to old DOM nodes need to be cleared to avoid memory leaks, and any event handlers not attached to the document object will need to be reregistered.