15

Is there any way in VS 2010 or 2012 to minify JavaScript files at the time of Publishing?

I want automatically minified js files. Any good example for compression?

Please note that I am not using MVC.

Rahatur
  • 3,147
  • 3
  • 33
  • 49
Rahul
  • 591
  • 1
  • 7
  • 21
  • 1
    Right now we run minification scripts in MSBuild file in an "AfterBuild" target. But it non-ideal and really slows down build time (especially for unit tests). – craastad Mar 08 '13 at 11:52

2 Answers2

6

Use MVC 4. It bundles multiple scripts and minifies them.

Jeroen
  • 4,023
  • 2
  • 24
  • 40
3

You can take a look at bundling and minification if you are using ASP.NET 4.5.

Sidharth Mudgal
  • 4,234
  • 19
  • 25
  • with minification can we minify it at publishing time ? – Rahul Nov 22 '12 at 05:58
  • I think its done at runtime, i.e., when a request is made. You can enable caching of course. – Sidharth Mudgal Nov 22 '12 at 07:21
  • 1
    Are there any (automated) ways of using ASP.NET bundling and minification without deploying the un-minified javascripts? For example, it may be fine for this to be done at runtime when the web application is being deployed your own server, but what if you are releasing a version for others to deploy onto their own intranet / server etc. and you don't want to include source? – Matt Wilson Mar 01 '13 at 15:04