Skip to content

Commit 30498cf

Browse files
committed
Updated readme, cleaned up comments, updated NuGet spec.
1 parent d68cf2f commit 30498cf

File tree

3 files changed

+54
-7
lines changed

3 files changed

+54
-7
lines changed

README.md

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,56 @@
11
RazorHtmlMinifier.Mvc5
22
======================
33

4-
*Razor HTML Minifier for ASP.NET MVC 5*
4+
[![Build status](https://ci.appveyor.com/api/projects/status/ii20k891o3t38q9k?svg=true)](https://ci.appveyor.com/project/tompazourek/razorhtmlminifier-mvc5)
55

6-
TODO
6+
*Trivial compile-time Razor HTML Minifier for ASP.NET MVC 5.*
7+
8+
Installation
9+
------------
10+
11+
### Download
12+
13+
Binaries of the last build can be downloaded on the [AppVeyor CI page of the project](https://ci.appveyor.com/project/tompazourek/razorhtmlminifier-mvc5/build/artifacts).
14+
15+
The library is also [published on NuGet.org](https://www.nuget.org/packages/RazorHtmlMinifier.Mvc5/), install using:
16+
17+
```
18+
PM> Install-Package RazorHtmlMinifier.Mvc5
19+
```
20+
21+
<sup>RazorHtmlMinifier.Mvc5 is is built as for .NET v4.5 with a dependency on ASP.NET MVC 5.2.3.</sup>
22+
23+
### Configuration
24+
25+
Find the **Web.config** with your Razor configuration (by default it's in `Views/Web.config`). You should see something like this inside:
26+
27+
```xml
28+
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
29+
```
30+
31+
In order to start minifying, replace it with (after the NuGet package is installed):
32+
33+
```xml
34+
<host factoryType="RazorHtmlMinifier.Mvc5.MinifyingMvcWebRazorHostFactory, RazorHtmlMinifier.Mvc5, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
35+
```
36+
37+
Then rebuild your solution, which should also restart the app.
38+
39+
40+
How it works
41+
------------
42+
43+
The minifier processes the code generated during Razor compilation. Because it runs in compile-time, it shouldn't add any overhead during runtime.
44+
45+
The entire source code is just a [single file](https://github.com/tompazourek/RazorHtmlMinifier.Mvc5/blob/master/src/RazorHtmlMinifier.Mvc5/MinifyingMvcWebRazorHostFactory.cs), feel free to view it.
46+
47+
The minification applied is very trivial as you can [see here](https://github.com/tompazourek/RazorHtmlMinifier.Mvc5/blob/master/src/RazorHtmlMinifier.Mvc5/MinifyingMvcWebRazorHostFactory.cs#L47-L55). It basically:
48+
49+
- replaces multiple white-space characters next to each other with a single space;
50+
- replaces multiple white-space characters containing line breaks with a single line break.
51+
52+
The minification process is deliberately trivial so that its behaviour would be easy to understand and expect.
53+
54+
**CAUTION! The minification is not context-sensitive, and it doesn't have any special handling of `<pre>` tags or similar. If you use `<pre>` tags or have any other significant white-space in your HTML, you shouldn't use this library.**
55+
56+
The code is inspired by [Meleze.Web](https://github.com/meleze/Meleze.Web) (an older project), but it's much simplified and updated to be used for with the latest version of ASP.NET MVC.

src/RazorHtmlMinifier.Mvc5/MinifyingMvcWebRazorHostFactory.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
namespace RazorHtmlMinifier.Mvc5
1212
{
13-
/// <summary>
14-
/// Simple minification of razor pages
15-
/// </summary>
1613
public class MinifyingMvcWebRazorHostFactory : MvcWebRazorHostFactory
1714
{
1815
public override WebPageRazorHost CreateHost(string virtualPath, string physicalPath)

src/RazorHtmlMinifier.Mvc5/RazorHtmlMinifier.Mvc5.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<PackageLicenseUrl>https://raw.githubusercontent.com/tompazourek/RazorHtmlMinifier.Mvc5/master/LICENSE</PackageLicenseUrl>
1414
<PackageProjectUrl>https://github.com/tompazourek/RazorHtmlMinifier.Mvc5</PackageProjectUrl>
1515
<RepositoryUrl>https://github.com/tompazourek/RazorHtmlMinifier.Mvc5</RepositoryUrl>
16-
<PackageTags>TODO</PackageTags>
17-
<Description>TODO</Description>
16+
<PackageTags>asp-net asp-net-mvc asp-net-mvc5 c-sharp cshtml html html-minification html-minifier minification minifier optimization razor razor-engine</PackageTags>
17+
<Description>Trivial compile-time Razor HTML Minifier for ASP.NET MVC 5.</Description>
1818
<RepositoryType>git</RepositoryType>
1919
<PackageReleaseNotes>https://github.com/tompazourek/RazorHtmlMinifier.Mvc5/releases</PackageReleaseNotes>
2020
<PackageId>RazorHtmlMinifier.Mvc5</PackageId>

0 commit comments

Comments
 (0)