I am working on optimizing a pretty large angularjs application with 100+ templates. I use grunt for automation. What i am trying to achieve here is that i need to prefix all the urls in my production code with a cdnUrl as I plan to host static assets on cdn.
I tried using this grunt plugin to do that and i was successfully to replace all references in my code except the templateUrls in <ng-include>
tags and those in UI routers state configuration.
Hence i thought of solving that issue by precompiling all my angular js templates into a single js file using $templateCache
service using this plugin. After checking out the size of the precompiled js file i found out it was a whopping 1.13 MB even with html minified.
Comparing that to my overall app it takes just 1.5 ~ 1.7 mb for my entire app during first load. So i don't find it legible to include this precompiled template which forces lot of extra weight to be downloaded on the user's device. Also there are some views which are partially restricted to some users and generally speaking i feel its unfair to load data for those sections of the app which many users won't be anyway visiting.
So what do you guys recommend in such cases ? Is it still preferable to use $templateCache in production? if not any help regarding prefixing angular templates with cdn url using grunt will be helpful.