Use jsmin to minify javascript

10/24/2013 3:24:49 AM

Use the following to use jsmin to minify javascript files.

1) Right Click Visual Studio Project and click Properties
2) Go to Build Events
3) Edit Post-build events and add the following (add your path to your jsmin exe).

"c:\projects\utilities\jsmin\jsmin" < "$(ProjectDir)Scripts\common.js" > "$(ProjectDir)Scripts\common.min.js"

4) Include both minified and unminified js files to your project.
5) Exclude the uniminified from being publshed.
6) Add an if statement within your views (or pages) to load the unminified when url containts localhost and the minified version else.