minify_html 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +36 -34
- 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 +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ac8cbe2a24743c576effe99e4939533da0826c3e5e460b0b1a59268516aef52
|
4
|
+
data.tar.gz: 12d1e2786e277c1b3eda39ab17daa9aae14623573aa06b0ddc4773ceb405d19f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef289f74abbc2070211d94a0dee6f201cffc0edb340e822c27420f965824456f174114850bca2c80a48f1a903f0571b51045c639c4d678c076840ea28c04329a
|
7
|
+
data.tar.gz: 150e46bc7dff5da38d56c8415f3420f5c7d69f218ba0a19f6639bb0df03d33ea40571ba496a2e81a15cb7a284222fab2896a008a3fc8e1a26653d988f750e1d9
|
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,42 @@ 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 and compression of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.
|
22
|
+
<img width="415" alt="Chart showing speed and compression of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.6.0/core/average-combined.png">
|
23
23
|
|
24
24
|
Need even faster performance? Check the [one](https://github.com/wilsonzlin/minify-html/tree/one) branch.
|
25
25
|
|
26
26
|
## Usage
|
27
27
|
|
28
28
|
<details>
|
29
|
-
<summary><img width="24" src="
|
29
|
+
<summary><img width="24" src="https://wilsonl.in/minify-html/icon/cli.png"> <strong>CLI</strong></summary>
|
30
30
|
|
31
|
-
Precompiled binaries are available for
|
31
|
+
Precompiled binaries are available for Linux, macOS, and Windows.
|
32
32
|
|
33
33
|
### Get
|
34
34
|
|
35
|
-
[Linux](https://wilsonl.in/minify-html/bin/0.
|
36
|
-
[
|
37
|
-
[
|
35
|
+
[Linux x86-64](https://wilsonl.in/minify-html/bin/0.6.0-linux-x86_64) |
|
36
|
+
[Linux ARM](https://wilsonl.in/minify-html/bin/0.6.0-linux-arm64) |
|
37
|
+
[macOS](https://wilsonl.in/minify-html/bin/0.6.0-macos-x86_64) |
|
38
|
+
[Windows](https://wilsonl.in/minify-html/bin/0.6.0-windows-x86_64.exe)
|
38
39
|
|
39
40
|
### Use
|
40
41
|
|
41
42
|
Use the `--help` argument for more details.
|
42
43
|
|
43
44
|
```bash
|
44
|
-
minify-html --
|
45
|
+
minify-html --output /path/to/output.min.html --keep-closing-tags --minify-css /path/to/src.html
|
45
46
|
```
|
46
47
|
|
47
48
|
</details>
|
48
49
|
|
49
50
|
<details>
|
50
|
-
<summary><img width="24" src="
|
51
|
+
<summary><img width="24" src="https://wilsonl.in/minify-html/icon/rust.png"> <strong>Rust</strong></summary>
|
51
52
|
|
52
53
|
### Get
|
53
54
|
|
54
55
|
```toml
|
55
56
|
[dependencies]
|
56
|
-
minify-html = { version = "0.
|
57
|
+
minify-html = { version = "0.6.0", features = ["js-esbuild"] }
|
57
58
|
```
|
58
59
|
|
59
60
|
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 +68,7 @@ Check out the [docs](https://docs.rs/minify-html) for API and usage examples.
|
|
67
68
|
</details>
|
68
69
|
|
69
70
|
<details>
|
70
|
-
<summary><img width="24" src="
|
71
|
+
<summary><img width="24" src="https://wilsonl.in/minify-html/icon/nodejs.png"> <strong>Node.js</strong></summary>
|
71
72
|
|
72
73
|
- Package: [@minify-html/js](https://www.npmjs.com/package/@minify-html/js)
|
73
74
|
- Binding: [N-API](https://nodejs.org/api/n-api.html)
|
@@ -93,7 +94,7 @@ yarn add @minify-html/js
|
|
93
94
|
const minifyHtml = require("@minify-html/js");
|
94
95
|
|
95
96
|
// Refer to TypeScript definitions for details.
|
96
|
-
const cfg = minifyHtml.createConfiguration({
|
97
|
+
const cfg = minifyHtml.createConfiguration({ keep_closing_tags: true, remove_bangs: false });
|
97
98
|
const minified = minifyHtml.minify("<p> Hello, world! </p>", cfg);
|
98
99
|
```
|
99
100
|
|
@@ -103,14 +104,14 @@ minify-html is also available for TypeScript:
|
|
103
104
|
import * as minifyHtml from "@minify-html/js";
|
104
105
|
import * as fs from "fs";
|
105
106
|
|
106
|
-
const cfg = minifyHtml.createConfiguration({
|
107
|
+
const cfg = minifyHtml.createConfiguration({ keep_spaces_between_attributes: true, keep_comments: true });
|
107
108
|
const minified = minifyHtml.minify("<p> Hello, world! </p>", cfg);
|
108
109
|
```
|
109
110
|
|
110
111
|
</details>
|
111
112
|
|
112
113
|
<details>
|
113
|
-
<summary><img width="24" src="
|
114
|
+
<summary><img width="24" src="https://wilsonl.in/minify-html/icon/java.png"> <strong>Java</strong></summary>
|
114
115
|
|
115
116
|
- Package: [in.wilsonl.minifyhtml](https://search.maven.org/artifact/in.wilsonl.minifyhtml/minify-html)
|
116
117
|
- Binding: [JNI](https://github.com/jni-rs/jni-rs)
|
@@ -124,7 +125,7 @@ Add as a Maven dependency:
|
|
124
125
|
<dependency>
|
125
126
|
<groupId>in.wilsonl.minifyhtml</groupId>
|
126
127
|
<artifactId>minify-html</artifactId>
|
127
|
-
<version>0.
|
128
|
+
<version>0.6.0</version>
|
128
129
|
</dependency>
|
129
130
|
```
|
130
131
|
|
@@ -136,8 +137,8 @@ import in.wilsonl.minifyhtml.MinifyHtml;
|
|
136
137
|
import in.wilsonl.minifyhtml.SyntaxException;
|
137
138
|
|
138
139
|
Configuration cfg = new Configuration.Builder()
|
139
|
-
.
|
140
|
-
.setMinifyCss(
|
140
|
+
.setKeepHtmlAndHeadOpeningTags(true)
|
141
|
+
.setMinifyCss(true)
|
141
142
|
.build();
|
142
143
|
|
143
144
|
String minified = MinifyHtml.minify("<p> Hello, world! </p>", cfg);
|
@@ -146,7 +147,7 @@ String minified = MinifyHtml.minify("<p> Hello, world! </p>", cfg);
|
|
146
147
|
</details>
|
147
148
|
|
148
149
|
<details>
|
149
|
-
<summary><img width="24" src="
|
150
|
+
<summary><img width="24" src="https://wilsonl.in/minify-html/icon/python.png"> <strong>Python</strong></summary>
|
150
151
|
|
151
152
|
- Package: [minify-html](https://pypi.org/project/minify-html)
|
152
153
|
- Binding: [PyO3](https://github.com/PyO3/pyo3)
|
@@ -161,13 +162,13 @@ Add the PyPI project as a dependency and install it using `pip` or `pipenv`.
|
|
161
162
|
```python
|
162
163
|
import minify_html
|
163
164
|
|
164
|
-
minified = minify_html.minify("<p> Hello, world! </p>", minify_js=
|
165
|
+
minified = minify_html.minify("<p> Hello, world! </p>", minify_js=True, remove_processing_instructions=True)
|
165
166
|
```
|
166
167
|
|
167
168
|
</details>
|
168
169
|
|
169
170
|
<details>
|
170
|
-
<summary><img width="24" src="
|
171
|
+
<summary><img width="24" src="https://wilsonl.in/minify-html/icon/ruby.png"> <strong>Ruby</strong></summary>
|
171
172
|
|
172
173
|
- Package: [minify_html](https://rubygems.org/gems/minify_html)
|
173
174
|
- Binding: [Rutie](https://github.com/danielpclark/rutie)
|
@@ -182,14 +183,14 @@ Add the library as a dependency to `Gemfile` or `*.gemspec`.
|
|
182
183
|
```ruby
|
183
184
|
require 'minify_html'
|
184
185
|
|
185
|
-
print MinifyHtml.minify("<p> Hello, world! </p>", { :
|
186
|
+
print MinifyHtml.minify("<p> Hello, world! </p>", { :keep_spaces_between_attributes => true, :minify_js => true })
|
186
187
|
```
|
187
188
|
|
188
189
|
</details>
|
189
190
|
|
190
191
|
## Minification
|
191
192
|
|
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.
|
193
|
+
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
194
|
|
194
195
|
### Whitespace
|
195
196
|
|
@@ -383,7 +384,7 @@ These elements are usually like content elements but are occasionally used like
|
|
383
384
|
|
384
385
|
### Tags
|
385
386
|
|
386
|
-
[Optional closing tags](https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission) are removed.
|
387
|
+
[Optional opening and closing tags](https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission) are removed.
|
387
388
|
|
388
389
|
### Attributes
|
389
390
|
|
@@ -393,16 +394,16 @@ Any entities in attribute values are decoded, and then the shortest representati
|
|
393
394
|
- Single quoted, with any `'` encoded.
|
394
395
|
- Unquoted, with `"`/`'` first character (if applicable), any `>`, and any whitespace encoded.
|
395
396
|
|
396
|
-
|
397
|
+
Attributes have their whitespace (after any decoding) trimmed and collapsed when possible.
|
397
398
|
|
398
|
-
[Boolean attribute](
|
399
|
-
[Some other attributes](
|
399
|
+
[Boolean attribute](https://github.com/wilsonzlin/html-data) values are removed.
|
400
|
+
[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
401
|
|
401
402
|
`type` attributes on `script` tags with a value equaling a [JavaScript MIME type](https://mimesniff.spec.whatwg.org/#javascript-mime-type) are removed.
|
402
403
|
|
403
404
|
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
405
|
|
405
|
-
Spaces are removed between attributes
|
406
|
+
Spaces are removed between attributes when possible.
|
406
407
|
|
407
408
|
### Entities
|
408
409
|
|
@@ -410,7 +411,8 @@ Entities are decoded if they're valid and shorter or equal in length when decode
|
|
410
411
|
|
411
412
|
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
413
|
|
413
|
-
|
414
|
+
Encoding is avoided when possible; for example, `<` are only encoded in content if they are followed by a valid tag name character.
|
415
|
+
If necessary, the shortest entity representation is chosen.
|
414
416
|
|
415
417
|
### Comments
|
416
418
|
|
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.0
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fiddle
|