I have a project that is client-side heavy with jquery and the dhtmlx interface library and utilizing MVC & entity framework on the server side. I started building the JavaScript inside my views (.cshtml). But I knew at some point I was going to need to pull the JavaScript out into its own file (a trivial task), and Minify the code for at least a small degree of security.
Well, today was that day. After breaking the code into its own file, I set out to figure out how to automatically Minify the code. I had used online tools in the past to manually Minify my code, but in this day of automated build processes, I decided that a more automated approach was in order.
I googled obfuscated JavaScript and found that the most prevalent library seemed to the the YUICompressor from Yahoo, but the latest online tool seemded to be the Google Closure Compiler which has three modes: pretty, standard and advanced. Pretty simply structures your code to make it more readable with proper indentation and consistent block structures. Standard does the standard white space compression while advanced actually does code optimization and elimination of unreachable code. After choosing the google option, I also learned that perhaps there's a minifier included with visual studio?, but I ignored that option.
More on this subject later...
No comments:
Post a Comment