precompile angular js template to speed up application startup
angularjs, javascript, precompile, templates
Solution
It appears I was wrong, what takes time isn't to compile the templates. The browser is just slow to load all the page and basically the document.ready event took some time to be fired.
To fix this I only include my main template `<script type="text/ng-template" id="/myMainTemplate.html">...</script>` in the page, and I load the other templates using an asynch $http call, based on this solution : https://gist.github.com/vojtajina/3354046
Problem
I have a big angular application with 5 templates included in the main page using ``` <script type="text/ng-template" id="/myMainTemplate.html">...</script> <script type="text/ng-template" id="/myTemplatePage2.html">...</script> <script type="text/ng-template" id="/myTemplatePage3.html">...</script> <script type="text/ng-template" id="/myTemplatePage4.html">...</script> ``` However, my application takes a lot of time to startup. Removing the templates 2/3/4 fix it but of course broke the app, my guess is that angularjs takes too much time to compile the 5 templates. Is there a way to pre-compile angularjs templates, for example with nodejs or something similar (the same way we can compile templates with handlebar maybe) ? If I understand well the `$compile` instruction, the idea would be to move the instruction `$compile(myTemplate)` in the server-side inside of the client