Anton Fisher
Anton Fisher

Reputation: 11

how to compress css and js files?

In my project we dont use iis compress , becose we use custom CompressFilterAttribute. For views works correctly. I need to compress css and js files. Someone have any ideas?

Upvotes: 0

Views: 2577

Answers (2)

Damian S
Damian S

Reputation: 156

Boundling is great approach, you can also try tools to minification js, less, css, coffiescript, and images.

http://visualstudiogallery.msdn.microsoft.com/a56eddd3-d79b-48ac-8c8f-2db06ade77c3 -> images http://visualstudiogallery.msdn.microsoft.com/07d54d12-7133-4e15-becb-6f451ea3bea6 -> others

Upvotes: 0

Knaģis
Knaģis

Reputation: 21485

The most common approach in ASP.NET MVC is to use content bundling: http://weblogs.asp.net/scottgu/archive/2011/11/27/new-bundling-and-minification-support-asp-net-4-5-series.aspx

Also note that in IIS you enable static and dynamic content compression separately. To compress JS and CSS you need to enable just the static compression. You would not use dynamic compression in IIS since you are doing that in code. Although if you would enable it as well, it would still work - IIS would detect when the content is already compressed from the code and not do anything else with it.

Upvotes: 5

Related Questions