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?
-
3Check out bundling and minification.Henk Mollema– Henk Mollema2013-10-15 14:20:28 +00:00Commented Oct 15, 2013 at 14:20
-
Duplicate of Combining and minifying JS and CSS in ASP.NET MVC, first web search hit on "mvc compress css js". Please show research effort. :-)CodeCaster– CodeCaster2013-10-15 14:29:28 +00:00Commented Oct 15, 2013 at 14:29
-
if you to bundling files it dont means that compress this filesAnton Fisher– Anton Fisher2013-10-15 15:25:14 +00:00Commented Oct 15, 2013 at 15:25
2 Answers
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.
2 Comments
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