• Stars
    star
    134
  • Rank 270,967 (Top 6 %)
  • Language
    C#
  • License
    MIT License
  • Created about 11 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple command line tool to minify your HTML, Razor views & Web Forms views

HTML Minifier

A simple command line tool to minify your HTML, Razor views & Web Forms views. By minifying your HTML on bigger web pages, you will save on bytes that your users need to donwload. Less bytes equal faster web pages & faster web pages equal happy users!

Getting Started

Go from HTML that looks like this:

<h2>
    Admin Menu</h2>
<ul>
    <li>@Html.ActionLink("Edit blog entries", "List", "Admin")</li>
    <li>@Html.ActionLink("View Comments", "CommentList", "Admin")</li>
    <li>@Html.ActionLink("Clear Cache", "ClearCache", "Admin")</li>
</ul>

To HTML that looks like this:

<h2> Admin Menu</h2><ul><li>@Html.ActionLink("Edit blog entries", "List", "Admin")</li><li>@Html.ActionLink("View Comments", "CommentList", "Admin")</li><li>@Html.ActionLink("Clear Cache", "ClearCache", "Admin")</li></ul>

Usage Examples

In order to use from the command line, you simply pass through a folder path that contains all of the files you want to minify. The minifier will process all images in the root and subfolders.

C:\>HtmlMinifier.exe "C:\Folder"

If you'd like to restrict the number of characters per line and force it to break to the next line, use the minifier with the following optional value (where the number is the max character count).

C:\>HtmlMinifier.exe "C:\Folder" "60000"

There is also the option to disable certain minification features. For example, if you use a you rely on HTML comments (Knockout, Angular, etc.) you might want to leave them in the minified HTML.

C:\>HtmlMinifier.exe "C:\Folder" ignorehtmlcomments

You can also disable the minification of JavaScript Comments

C:\>HtmlMinifier.exe "C:\Folder" ignorejscomments

If you use knockoutJS, you can optionally disable the minification of Knockout Comments

C:\>HtmlMinifier.exe "C:\Folder" ignoreknockoutcomments

If you want to minify individual folders you can do:

C:\>HtmlMinifier.exe "C:\Folder\fld1" "C:\Folder\fld2"

If you want to minify individual files you can do:

C:\>HtmlMinifier.exe "C:\Folder\file1.html" "C:\Folder\file2.html"

If you'd like to find out how to use this with MSBUILD and your next publish, please follow this link.

License

(C) Dean Hume 2022, released under the MIT license

More Repositories

1

typography

A collection of web typography resources
634
star
2

progressive-web-apps-book

All of the code for "Progressive Apps" - a book by Dean Hume
HTML
303
star
3

pwa-update-available

Service Workers - New Update Available sample
HTML
254
star
4

lazy-observer-load

A library to lazy load images using Intersection Observer
JavaScript
244
star
5

image-beast

My 10K apart entry - A handy 1KB script that decides the leanest image format to return based on your browser.
HTML
157
star
6

pwa-tips-tricks

A big list of Progressive Web App tips & tricks!
137
star
7

beer

The source code for the Progressive Beer app!
JavaScript
74
star
8

Service-Worker-Offline

A really, really simple offline page using Service Workers
JavaScript
50
star
9

streams

Experimenting with the Streams spec
JavaScript
31
star
10

ImageOptimizer

A collection of image optimization techniques
C#
28
star
11

Service-Workers-BackgroundSync

A simple example using Service Workers & Background Sync
HTML
26
star
12

SignalRUsersOnline

Get the count of users online using SignalR
23
star
13

pwa-connection-type

A tiny service worker script to change image quality dependant on connection type (2G, 3G, etc)
JavaScript
23
star
14

Service-Workers-HTTP2-Push

An example using HTTP/2 push and Service Workers to achieve super fast load times
JavaScript
22
star
15

firebase-example

A simple firebase site example
HTML
11
star
16

FastASPNetWebsites

The source code for the Fast ASP.NET websites book
PowerShell
11
star
17

Service-Workers-WebP

A simple example using HTTP Client Hints and Service Worker
HTML
10
star
18

Service-Workers-Fetch-Timeout

A simple example using timeouts and service workers
JavaScript
9
star
19

pwa-cloudinary

JavaScript
6
star
20

ambient-light-sensor

Experimenting with the Ambient Light Sensor in Chrome
HTML
6
star
21

speedindex-test

A example page that demos the https://github.com/WPO-Foundation/RUM-SpeedIndex library
JavaScript
5
star
22

http2-test

A simple test example to run HTTP2
JavaScript
4
star
23

Service-Worker-Toolbox

A demo repo using the Service Worker Toolbox
JavaScript
4
star
24

buildingstartupteams.com

The code repo for buildingstartupteams.com
HTML
3
star
25

web-share

A playground for the Web Share API
HTML
3
star
26

UpFrontConf

A site optimization example
HTML
2
star
27

real-performance-metrics

A basic performance tracker that measures first paint, first contentful paint, and time to interactive.
JavaScript
2
star
28

daily-dashboard

A daily dashboard for home use.
JavaScript
1
star
29

settled

A protoype messaging / booking application for Settled
JavaScript
1
star
30

CodeGenerateMe

The source code for the website - codegenerate.me
C#
1
star
31

SmushMySite

SmushMySite is an image optimization tool that takes advantage of the Yahoo Smush.itโ„ข service. It is a quick and easy way to optimize all images on webpage, or all images on your site. It is developed in C# and WPF.
C#
1
star