Are pre-compiled templates useful for non-node sites?

163 views Asked by At

I have been researching methods for pre-compiling my _underscore templates and am beginning to think that 99% of people who are pre-compiling their templates seem to be running node.

This makes me think that maybe pre-compiling is intended to only be beneficial for rendering templates on the server instead of the client.

Is this true?

Is there any benefit in compiling temnplates on the server which will only be rendered in the client?

1

There are 1 answers

2
ebohlman On BEST ANSWER

"Really only useful" is a little subjective, don't you think? If you're asking about whether it's more important to pre-compile templates used server-side as opposed to client-side, it usually is, simply because a server is going to have to render them potentially several thousand times a second so it's wasteful to have to compile them each time they're rendered.

In a client-side app, the main concern is whether there's any user-noticeable slowdown associated with rendering templates. There usually isn't, and if there is, generally only a few (maybe partial templates used to build large list views) are responsible. So in most client-side apps, pre-compiling templates is a form of premature optimization.