minify_html 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +38 -35
- data/lib/linux-ruby2.5 +0 -0
- data/lib/linux-ruby2.6 +0 -0
- data/lib/linux-ruby2.7 +0 -0
- data/lib/macos-ruby2.5 +0 -0
- data/lib/macos-ruby2.6 +0 -0
- data/lib/macos-ruby2.7 +0 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2296251f24e9c0ece83df1ad6fc22f41b5adbfc1368b34b18b28b547cf35652c
|
4
|
+
data.tar.gz: 8c2b2faeca970134afd59a9bbf0aa9d4367664d850715ae0de5c86e060a1749e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1d6000d7d20fed0796ae8c6c25af8a265f0752a95d5de35abce16d8076bec9320ae668e10d6c888f834806604f30b3d3bd81ddeea90088bb952cf1e4b546de6
|
7
|
+
data.tar.gz: e98302877ae98f160f97ea206a00591ff3ffe11b973f803b3eb0e3b54c1c7315ecd89252ab34926b01e4eb2fa480629cd5d670fe3cfa2f1b36c57a2ec24cc274
|
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
<h1>
|
2
2
|
minify-html
|
3
|
-
<img width="24" src="
|
4
|
-
<img width="24" src="
|
5
|
-
<img width="24" src="
|
6
|
-
<img width="24" src="
|
7
|
-
<img width="24" src="
|
8
|
-
<img width="24" src="
|
3
|
+
<img width="24" src="https://wilsonl.in/minify-html/icon/cli.png">
|
4
|
+
<img width="24" src="https://wilsonl.in/minify-html/icon/java.png">
|
5
|
+
<img width="24" src="https://wilsonl.in/minify-html/icon/nodejs.png">
|
6
|
+
<img width="24" src="https://wilsonl.in/minify-html/icon/python.png">
|
7
|
+
<img width="24" src="https://wilsonl.in/minify-html/icon/ruby.png">
|
8
|
+
<img width="24" src="https://wilsonl.in/minify-html/icon/rust.png">
|
9
9
|
</h1>
|
10
10
|
|
11
|
-
|
11
|
+
A Rust HTML minifier meticulously optimised for speed and effectiveness, with bindings for other languages.
|
12
12
|
|
13
13
|
- Advanced minification strategy beats other minifiers while being much faster.
|
14
14
|
- Uses SIMD searching, direct tries, and lookup tables.
|
@@ -19,41 +19,43 @@ An HTML minifier meticulously optimised for both speed and effectiveness, writte
|
|
19
19
|
|
20
20
|
Comparison with [html-minfier](https://github.com/kangax/html-minifier) and [minimize](https://github.com/Swaagie/minimize), run on the top web pages. [See the breakdown here.](./bench)
|
21
21
|
|
22
|
-
<img width="415" alt="Chart showing speed
|
22
|
+
<img width="415" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.6.1/core/average-speeds.png">
|
23
|
+
<img width="415" alt="Chart showing compression of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.6.1/core/average-sizes.png">
|
23
24
|
|
24
|
-
|
25
|
+
The [onepass](https://github.com/wilsonzlin/minify-html/tree/master/rust/onepass) variant is even more optimised for speed. See its [README](https://github.com/wilsonzlin/minify-html/tree/master/rust/onepass) for more details.
|
25
26
|
|
26
27
|
## Usage
|
27
28
|
|
28
29
|
<details>
|
29
|
-
<summary><img width="24" src="
|
30
|
+
<summary><img width="24" src="https://wilsonl.in/minify-html/icon/cli.png"> <strong>CLI</strong></summary>
|
30
31
|
|
31
|
-
Precompiled binaries are available for
|
32
|
+
Precompiled binaries are available for Linux, macOS, and Windows.
|
32
33
|
|
33
34
|
### Get
|
34
35
|
|
35
|
-
[Linux](https://wilsonl.in/minify-html/bin/0.
|
36
|
-
[
|
37
|
-
[
|
36
|
+
[Linux x86-64](https://wilsonl.in/minify-html/bin/0.6.1-linux-x86_64) |
|
37
|
+
[Linux ARM](https://wilsonl.in/minify-html/bin/0.6.1-linux-arm64) |
|
38
|
+
[macOS](https://wilsonl.in/minify-html/bin/0.6.1-macos-x86_64) |
|
39
|
+
[Windows](https://wilsonl.in/minify-html/bin/0.6.1-windows-x86_64.exe)
|
38
40
|
|
39
41
|
### Use
|
40
42
|
|
41
43
|
Use the `--help` argument for more details.
|
42
44
|
|
43
45
|
```bash
|
44
|
-
minify-html --
|
46
|
+
minify-html --output /path/to/output.min.html --keep-closing-tags --minify-css /path/to/src.html
|
45
47
|
```
|
46
48
|
|
47
49
|
</details>
|
48
50
|
|
49
51
|
<details>
|
50
|
-
<summary><img width="24" src="
|
52
|
+
<summary><img width="24" src="https://wilsonl.in/minify-html/icon/rust.png"> <strong>Rust</strong></summary>
|
51
53
|
|
52
54
|
### Get
|
53
55
|
|
54
56
|
```toml
|
55
57
|
[dependencies]
|
56
|
-
minify-html = { version = "0.
|
58
|
+
minify-html = { version = "0.6.1", features = ["js-esbuild"] }
|
57
59
|
```
|
58
60
|
|
59
61
|
Building with the `js-esbuild` feature requires the Go compiler to be installed as well, to build the [JS and CSS minifier](https://github.com/wilsonzlin/esbuild-rs).
|
@@ -67,7 +69,7 @@ Check out the [docs](https://docs.rs/minify-html) for API and usage examples.
|
|
67
69
|
</details>
|
68
70
|
|
69
71
|
<details>
|
70
|
-
<summary><img width="24" src="
|
72
|
+
<summary><img width="24" src="https://wilsonl.in/minify-html/icon/nodejs.png"> <strong>Node.js</strong></summary>
|
71
73
|
|
72
74
|
- Package: [@minify-html/js](https://www.npmjs.com/package/@minify-html/js)
|
73
75
|
- Binding: [N-API](https://nodejs.org/api/n-api.html)
|
@@ -93,7 +95,7 @@ yarn add @minify-html/js
|
|
93
95
|
const minifyHtml = require("@minify-html/js");
|
94
96
|
|
95
97
|
// Refer to TypeScript definitions for details.
|
96
|
-
const cfg = minifyHtml.createConfiguration({
|
98
|
+
const cfg = minifyHtml.createConfiguration({ keep_closing_tags: true, remove_bangs: false });
|
97
99
|
const minified = minifyHtml.minify("<p> Hello, world! </p>", cfg);
|
98
100
|
```
|
99
101
|
|
@@ -103,14 +105,14 @@ minify-html is also available for TypeScript:
|
|
103
105
|
import * as minifyHtml from "@minify-html/js";
|
104
106
|
import * as fs from "fs";
|
105
107
|
|
106
|
-
const cfg = minifyHtml.createConfiguration({
|
108
|
+
const cfg = minifyHtml.createConfiguration({ keep_spaces_between_attributes: true, keep_comments: true });
|
107
109
|
const minified = minifyHtml.minify("<p> Hello, world! </p>", cfg);
|
108
110
|
```
|
109
111
|
|
110
112
|
</details>
|
111
113
|
|
112
114
|
<details>
|
113
|
-
<summary><img width="24" src="
|
115
|
+
<summary><img width="24" src="https://wilsonl.in/minify-html/icon/java.png"> <strong>Java</strong></summary>
|
114
116
|
|
115
117
|
- Package: [in.wilsonl.minifyhtml](https://search.maven.org/artifact/in.wilsonl.minifyhtml/minify-html)
|
116
118
|
- Binding: [JNI](https://github.com/jni-rs/jni-rs)
|
@@ -124,7 +126,7 @@ Add as a Maven dependency:
|
|
124
126
|
<dependency>
|
125
127
|
<groupId>in.wilsonl.minifyhtml</groupId>
|
126
128
|
<artifactId>minify-html</artifactId>
|
127
|
-
<version>0.
|
129
|
+
<version>0.6.1</version>
|
128
130
|
</dependency>
|
129
131
|
```
|
130
132
|
|
@@ -136,8 +138,8 @@ import in.wilsonl.minifyhtml.MinifyHtml;
|
|
136
138
|
import in.wilsonl.minifyhtml.SyntaxException;
|
137
139
|
|
138
140
|
Configuration cfg = new Configuration.Builder()
|
139
|
-
.
|
140
|
-
.setMinifyCss(
|
141
|
+
.setKeepHtmlAndHeadOpeningTags(true)
|
142
|
+
.setMinifyCss(true)
|
141
143
|
.build();
|
142
144
|
|
143
145
|
String minified = MinifyHtml.minify("<p> Hello, world! </p>", cfg);
|
@@ -146,7 +148,7 @@ String minified = MinifyHtml.minify("<p> Hello, world! </p>", cfg);
|
|
146
148
|
</details>
|
147
149
|
|
148
150
|
<details>
|
149
|
-
<summary><img width="24" src="
|
151
|
+
<summary><img width="24" src="https://wilsonl.in/minify-html/icon/python.png"> <strong>Python</strong></summary>
|
150
152
|
|
151
153
|
- Package: [minify-html](https://pypi.org/project/minify-html)
|
152
154
|
- Binding: [PyO3](https://github.com/PyO3/pyo3)
|
@@ -161,13 +163,13 @@ Add the PyPI project as a dependency and install it using `pip` or `pipenv`.
|
|
161
163
|
```python
|
162
164
|
import minify_html
|
163
165
|
|
164
|
-
minified = minify_html.minify("<p> Hello, world! </p>", minify_js=
|
166
|
+
minified = minify_html.minify("<p> Hello, world! </p>", minify_js=True, remove_processing_instructions=True)
|
165
167
|
```
|
166
168
|
|
167
169
|
</details>
|
168
170
|
|
169
171
|
<details>
|
170
|
-
<summary><img width="24" src="
|
172
|
+
<summary><img width="24" src="https://wilsonl.in/minify-html/icon/ruby.png"> <strong>Ruby</strong></summary>
|
171
173
|
|
172
174
|
- Package: [minify_html](https://rubygems.org/gems/minify_html)
|
173
175
|
- Binding: [Rutie](https://github.com/danielpclark/rutie)
|
@@ -182,14 +184,14 @@ Add the library as a dependency to `Gemfile` or `*.gemspec`.
|
|
182
184
|
```ruby
|
183
185
|
require 'minify_html'
|
184
186
|
|
185
|
-
print MinifyHtml.minify("<p> Hello, world! </p>", { :
|
187
|
+
print MinifyHtml.minify("<p> Hello, world! </p>", { :keep_spaces_between_attributes => true, :minify_js => true })
|
186
188
|
```
|
187
189
|
|
188
190
|
</details>
|
189
191
|
|
190
192
|
## Minification
|
191
193
|
|
192
|
-
Note that some of the minification done can result in HTML that will not pass validation, but remain interpreted and rendered correctly by the browser; essentially, the laxness of the browser is taken advantage of for better minification. These can be turned off via the Cfg object.
|
194
|
+
Note that some of the minification done can result in HTML that will not pass validation, but remain interpreted and rendered correctly by the browser; essentially, the laxness of the browser is taken advantage of for better minification. These can be turned off via the `Cfg` object.
|
193
195
|
|
194
196
|
### Whitespace
|
195
197
|
|
@@ -383,7 +385,7 @@ These elements are usually like content elements but are occasionally used like
|
|
383
385
|
|
384
386
|
### Tags
|
385
387
|
|
386
|
-
[Optional closing tags](https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission) are removed.
|
388
|
+
[Optional opening and closing tags](https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission) are removed.
|
387
389
|
|
388
390
|
### Attributes
|
389
391
|
|
@@ -393,16 +395,16 @@ Any entities in attribute values are decoded, and then the shortest representati
|
|
393
395
|
- Single quoted, with any `'` encoded.
|
394
396
|
- Unquoted, with `"`/`'` first character (if applicable), any `>`, and any whitespace encoded.
|
395
397
|
|
396
|
-
|
398
|
+
Attributes have their whitespace (after any decoding) trimmed and collapsed when possible.
|
397
399
|
|
398
|
-
[Boolean attribute](
|
399
|
-
[Some other attributes](
|
400
|
+
[Boolean attribute](https://github.com/wilsonzlin/html-data) values are removed.
|
401
|
+
[Some other attributes](https://github.com/wilsonzlin/html-data) are completely removed if their value is empty or the default value after any processing.
|
400
402
|
|
401
403
|
`type` attributes on `script` tags with a value equaling a [JavaScript MIME type](https://mimesniff.spec.whatwg.org/#javascript-mime-type) are removed.
|
402
404
|
|
403
405
|
If an attribute value is empty after any processing, everything but the name is completely removed (i.e. no `=`), as an empty attribute is implicitly [the same](https://html.spec.whatwg.org/multipage/syntax.html#attributes-2) as an attribute with an empty string value.
|
404
406
|
|
405
|
-
Spaces are removed between attributes
|
407
|
+
Spaces are removed between attributes when possible.
|
406
408
|
|
407
409
|
### Entities
|
408
410
|
|
@@ -410,7 +412,8 @@ Entities are decoded if they're valid and shorter or equal in length when decode
|
|
410
412
|
|
411
413
|
Numeric entities that do not refer to a valid [Unicode Scalar Value](https://www.unicode.org/glossary/#unicode_scalar_value) are replaced with the [replacement character](https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character).
|
412
414
|
|
413
|
-
|
415
|
+
Encoding is avoided when possible; for example, `<` are only encoded in content if they are followed by a valid tag name character.
|
416
|
+
If necessary, the shortest entity representation is chosen.
|
414
417
|
|
415
418
|
### Comments
|
416
419
|
|
data/lib/linux-ruby2.5
CHANGED
Binary file
|
data/lib/linux-ruby2.6
CHANGED
Binary file
|
data/lib/linux-ruby2.7
CHANGED
Binary file
|
data/lib/macos-ruby2.5
CHANGED
Binary file
|
data/lib/macos-ruby2.6
CHANGED
Binary file
|
data/lib/macos-ruby2.7
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minify_html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wilson Lin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fiddle
|
@@ -39,7 +39,7 @@ files:
|
|
39
39
|
- lib/macos-ruby2.6
|
40
40
|
- lib/macos-ruby2.7
|
41
41
|
- lib/minify_html.rb
|
42
|
-
homepage: https://github.com/wilsonzlin/
|
42
|
+
homepage: https://github.com/wilsonzlin/minify-html
|
43
43
|
licenses:
|
44
44
|
- MIT
|
45
45
|
metadata: {}
|