It’s very common to minify a JS file. However when it comes to an Angular file, it might become a different story.
No matter if you are using a website compressor or you are using a YUI compressor. If you directly compress a angular js file, you might get an error about :$injector stuff in the browser console.
The main reason for this is that the compressor changes the arguments name of a function in the minified version of JS file, but this makes Angular confused.
You could follow the official doc about minification. However, if you are using angular in a more complicated way, the better solution might use a two-step to compress. (Better here I really means is safer).
In my case, I am also setting $interpolateProvider for the app. So the official doc seems only to tell me about $scope but not $interpolateProvider one.
Install ngmin. This could be done by
npm install -g ngmin
If you have npm installed.
ngmin somefile.js somefile.annotate.js
This basically generates a minify safe version of angular file. Say you have somefile.js which is an angular JS file. Then after running this, somefile.annotate.js is a minify safe JS file.
Use whatever you use to minify JS file to minify somefile.annotate.js you just got from Step One. Then the new minified angular JS file would work.