javascript - precompile angular js template to speed up application startup -
i have big angular application 5 templates included in 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, application takes lot of time startup.
removing templates 2/3/4 fix of course broke app, guess angularjs takes time compile 5 templates.
is there way pre-compile angularjs templates, example nodejs or similar (the same way can compile templates handlebar maybe) ?
if understand $compile
instruction, idea move instruction $compile(mytemplate)
in server-side inside of client
take @ grunt-html2js task.
https://github.com/karlgoldstein/grunt-html2js
it converts plain angular html templates javascript ready concatenating main app bundle. once templates in app bundle they'll primed in angular's template cache load instantly.
Comments
Post a Comment