Quantcast
Viewing all articles
Browse latest Browse all 3491

Re : Should I structure my whole html using template ?

Using client-side templates for your entire HTML is a bad idea.

There is a cost to rendering a template, especially if it is not precompiled. Here are the steps to render a template:

1) Fetch via Ajax
2) Parse and compile
3) Create DocumentFragment
4) Append to the document

1 & 2 are not needed if your template is compiled already, which happens if you steal your templates or use a tool like can-compile and include them in your production build.

So my advice would be to use templates only when you need to. If you are displaying a list of things retrieved from the server then yes, but you probably don't want to use a template to render static elements like your header, footer, etc unless you have a really good reason and know that the performance hit from all of the operations above is outweighed by the benefit you get from using a template.

Viewing all articles
Browse latest Browse all 3491

Trending Articles