-
Notifications
You must be signed in to change notification settings - Fork 10
HTML Minification of ASP.NET Razor views
License
meleze/Meleze.Web
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
To use the HTML Minification for Razor, you have to change your Views/Web.config to replace the default ASP.NET MVC factory by the Meleze's one: <configuration> <system.web.webPages.razor> <host factoryType="Meleze.Web.Razor.MinifyHtmlWebRazorHostFactory, Meleze.Web, Version=1.4.0.5, Culture=neutral, PublicKeyToken=0a868b5321967eda" /> </system.web.webPages.razor> </configuration> For ASP.NET MVC 3.0, use the 1.3 version of Meleze: <host factoryType="Meleze.Web.Razor.MinifyHtmlWebRazorHostFactory, Meleze.Web, Version=1.3.0.5, Culture=neutral, PublicKeyToken=0a868b5321967eda" /> There are two versions of the DLL: one for ASP.NET MVC3 and another for ASP.NET MVC4. Make sur to use the correct version (it is displayed in the DLL description). Making this change in the Web.config may break Intelliscense in Visual Studio if it does not find the Meleze.Web dll. There are two solutions: 1) You can setup the factory in Web.config.Release instead of the Web.config. The minification will be enabled only in release build. 2) Otherwize, you can register the Meleze.Web dll in the GAC using "gacutil.exe -i Meleze.Web". The minification will work even in design mode. The Minifier behavior can be configured in the application's root Web.config with some appSettings keys: <appSettings> <add key="meleze-minifier:Aggressive" value="true"/> <add key="meleze-minifier:Comments" value="true"/> <add key="meleze-minifier:Javascript" value="true"/> <add key="meleze-minifier:CSS" value="true"/> </appSettings> meleze-minifier:Aggressive removes as much whitespace as possible. In some cases, you may have to change yours CSS to fix the page layout (as whitespace is not interpreted in a compatible way by all browsers). meleze-minifier:Comments removes all the HTML comments that are neither Javascript code or conditional comments. meleze-minifier:Javascript calls the Microsoft Ajax Minifier. The AjaxMin.dll must be in the application references for this option to work (otherwise, JS is kept as is). meleze-minifier:CSS also calls the Microsoft Ajax Minifier to minimize the inline styles. There is also a NuGet package to setup the Minifier automatically in your applications. You can find more details in http://cestdumeleze.net/blog/2011/minifying-the-html-with-asp-net-mvc-and-razor/ RELEASE NOTES: - 1.4.6 and 1.3.6 (11/11/2013) - Fix integration with Microsoft AjaxMin (from SoonDead) - Fix minification of URL starting with ~/ - 1.4.5 and 1.3.5 (10/11/2013) - Fix integration with System.Web.Optimization - Add minification of the Razor sections - 1.4.4 and 1.3.4 (30/08/2013) - Fix bugs with the detection of Javascript // comments. - Minify the inline JS and CSS with the System.Web.Optimization if it is available. - 1.4.3 and 1.3.3 (4/24/2012) - Fix bug when inline Javascript contains // comments and that the Javascript minifier is not enabled. - Minify the inline CSS with the Microsoft Ajax Minifier (like for the inline Javascript).
About
HTML Minification of ASP.NET Razor views
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published