Minifying Javascript on Visual Studio 2010 on release mode

Posted by Arturo Molina on Stack Overflow See other posts from Stack Overflow or by Arturo Molina
Published on 2010-06-10T14:23:27Z Indexed on 2010/06/10 14:33 UTC
Read the original article Hit count: 397

I have a ASP.NET MVC 2 project on Visual Studio 2010. I want to be able to use my plain javascript files in debug mode so I can understand what's going on when debugging, but I want to used a minified/compressed version when using release mode.

I was planning to create some extenders to include the js files in each page, something like:

<%: Html.IncludeJS("/Content/foo.js") %>

In that extender method I would determine whether I am on debug or release mode and pick the appropiate JS file. The disadvantage here is that I would end up manually compressing/minifying the JS every time I change something.

Is there an automated way to compress/minify and include the JS file when compiling in release mode?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about asp.net-mvc