Pre-compile templates with client-side application — do we need it?

We are talking about compiling templates on the server under deployment or directly in front of the static content to the browser.

Why I had doubts — compiled templates are obviously larger than the uncompiled (for devices with poor Internet it's critical), but any decent template engine and so caches once compilenode (and even if not, it trevelino to do at the application level).
October 3rd 19 at 02:47
4 answers
October 3rd 19 at 02:49
Don't forget about gzip, it very vigorously you shake. And to compile on the client as it is not very good.
When gzip so clear.

And to compile on the client as it is not very good.
Why? - savannah_Emmerich12 commented on October 3rd 19 at 02:52
20KB templates the client will endure, and the additional load on the CPU already not very happy. Do you like when your laptop or smartphone after use turns into a hob? - corali commented on October 3rd 19 at 02:55
Well, if I'm such an idiot that compile all the templates, then Yes, the load will be. But if they are compiled only on request, it is unnoticed.

20 KB is not so little on EDGE or even GPRS. - savannah_Emmerich12 commented on October 3rd 19 at 02:58
I even so for compiling on the server, the tags you have overcame the handlebars, there is a wonderful thing as handlebars.runtime which you also size the application will save the expense of discarding the handlebars. - corali commented on October 3rd 19 at 03:01
October 3rd 19 at 02:51
You need a course, and how without it? If this client does not compile templates to all users of the site, a dozen templates over time, it will make no problems. Template engines work very quickly, even SmartyJS. Indeed, in this sense templates. Especially after a single compilation if a template is used constantly, it will not have to compile. Just don't compile all at once, but only out of necessity.
No, I mean predvaritelnaya compilation, before the return to the client. Right now, I will correct the title. - savannah_Emmerich12 commented on October 3rd 19 at 02:54
Then a few strange question. Where does the compiling on the server and Javascript, or use server-side JS? - corali commented on October 3rd 19 at 02:57
For simplicity, assume that, Yes, server-side JS. - savannah_Emmerich12 commented on October 3rd 19 at 03:00
Then does not matter. I do not think that will be too much difference in traffic or load when compiling the client, unless of course there is not a huge, complex patterns, though with a mustache the most challenging and will not do. Select the method which in the future is easier to maintain. Personally, I compile the templates out there where the main logic. - corali commented on October 3rd 19 at 03:03
October 3rd 19 at 02:53
You can not only compile, but for example cut gaps, and they often make up half of the template.
October 3rd 19 at 02:55
Then a few strange question. Where does the compiling on the server and Javascript, or use server-side JS?
Oh, do not write back - savannah_Emmerich12 commented on October 3rd 19 at 02:58

Find more questions by tags Client side optimizationJavaScriptHandlebars