forked from kangax/html-minifier
/
index.html
166 lines (164 loc) · 7.02 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>HTML minifier</title>
<script src="src/htmlparser.js" type="text/javascript"></script>
<script src="src/htmlminifier.js" type="text/javascript"></script>
<script src="src/htmllint.js" type="text/javascript"></script>
<link rel="stylesheet" href="master.css" type="text/css">
</head>
<body>
<div>
<div id="outer-wrapper">
<div id="wrapper">
<h1>HTML Minifier <span style="font-size:0.6em">(ver. 0.3)</span></h1>
<p id="warning">
Minifier is <strong>very draft</strong> and is <strong>not yet thoroughly tested</strong>. Use at your own risk.
</p>
<textarea rows="8" cols="40" id="input"></textarea>
<p style="width:65%">
<button type="button" id="minify-btn">Minify</button>
</p>
<textarea rows="8" cols="40" id="output" readonly></textarea>
</div>
<div id="options">
<ul>
<li>
<input type="checkbox" id="remove-comments" checked>
<label for="remove-comments">Remove comments</label>
<span class="quiet short" style="margin-left:1.5em;float:left;clear:both;">
Conditional comments are left intact.
</span>
</li>
<li>
<input type="checkbox" id="remove-comments-from-cdata" checked>
<label for="remove-comments-from-cdata">Also remove comments from scripts and styles</label>
</li>
<li>
<input type="checkbox" id="remove-cdata-sections-from-cdata" checked>
<label for="remove-cdata-sections-from-cdata">Remove CDATA sections from scripts and styles</label>
</li>
<li>
<input type="checkbox" id="collapse-whitespace" checked>
<label for="collapse-whitespace">Collapse whitespace</label>
</li>
<li>
<input type="checkbox" id="collapse-boolean-attributes" checked>
<label for="collapse-boolean-attributes">
Collapse boolean attributes
<br>
<span class="quiet short">
(e.g. <code><... disabled="disabled"> → <... disabled></code>)
</span>
</label>
</li>
<li>
<input type="checkbox" id="remove-attribute-quotes" checked>
<label for="remove-attribute-quotes">
Remove attribute quotes
<br>
<span class="quiet">
(e.g. <code><p class="foo"> → <p class=foo></code>)
</span>
</label>
</li>
<li>
<input type="checkbox" id="remove-redundant-attributes" checked>
<label for="remove-redundant-attributes">Remove redundant attributes/values</label>
<div class="quiet">
<code><script language="Javascript" ...></code><br>
<code><form method="get" ...></code><br>
<code><input type="text" ...></code><br>
<code><script src="..." charset="..."></code><br>
<code><a id="..." name="..."></code><br>
<code><... onclick="javascript:..." ...></code>
</div>
</li>
<li>
<input type="checkbox" id="use-short-doctype" checked>
<label for="use-short-doctype" title="i.e. <!DOCTYPE html>">
Use short doctype
</label>
</li>
<li>
<input type="checkbox" id="remove-empty-attributes" checked>
<label for="remove-empty-attributes">
Remove empty (or blank) attributes
<br>
<span class="quiet short">
Valid attributes are: class, id, style, title, lang, dir, event attributes
</span>
</label>
</li>
<li>
<input type="checkbox" id="remove-optional-tags" checked>
<label for="remove-optional-tags">
Remove optional tags
<br>
<span class="quiet short">
Currently, only:
<code></html></code>,
<code></head></code>,
<code></body></code>,
<code></thead></code>,
<code></tbody></code>,
<code></tfoot></code>,
and
<code></tr></code>
</span>
</label>
</li>
<li>
<input type="checkbox" id="remove-empty-elements">
<label for="remove-empty-elements">
Remove empty elements
<br>
<span class="quiet short">
All except <code>textarea</code>
</span>
</label>
</li>
<li>
<input type="checkbox" id="use-htmllint" checked>
<label for="use-htmllint">
Validate input through HTML lint
</label>
</li>
</ul>
</div>
</div>
<p id="stats"></p>
<div id="lint-report">
LINT REPORT:
<div id="report"></div>
</div>
<div id="todo">
TODO:
<ul>
<li>Unit test HTMLLint</li>
<li>Strip whitespace from attributes where allowed</li>
<li>Add option to collapse all whitespace to 1 character, instead of completely removing it (to preserve empty text nodes)</li>
<li>Figure out when it is safe to remove optional closing tags, so that it doesn't affect document tree</li>
<li>Support IE "Downlevel-revealed Conditional Comments"</li>
<li>Remove as many empty/blank attributes as possible (not just core ones)</li>
<li>Parser trips over xml declarations (need to ignore or strip them)</li>
<li>Generate a report of all applied transformations</li>
</ul>
<ul>
<li>HTMLLint: warn about repeating attributes (e.g. multiple styles, classes, etc.)</li>
<li>HTMLLint: warn about repeating &nbsp; or <br> sequences</li>
<li>HTMLLint: warn about missing doctype</li>
</ul>
</div>
<p class="quiet" style="font-style:italic;">
HTMLMinifier is made by <a href="http://perfectionkills.com/">kangax</a>,
using tweaked version of HTML parser by <a href="http://ejohn.org/">John Resig</a>
(which, in its turn, is based on work of <a href="http://erik.eae.net/">Erik Arvidsson</a>).
Source and bugtracker are <a href="http://github.com/kangax/html-minifier">hosted on Github</a>.
</p>
</div>
<script src="master.js" type="text/javascript"></script>
</body>
</html>