minify_html 0.5.2 → 0.6.2
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 +37 -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: 37fc43eb592e764f23574ebbf4b8b7495f87c6656594afc0014c723bca274219
|
4
|
+
data.tar.gz: 9d6b46251ab1555ea07c0db14e655bc3fb3a9aa4b99ff2e97779496c77428e50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6d860d8e6d3f9adf9164c031d18475647b1cf1ccf3a7c42f29149385f5ccc39b1736e761f5ba1c34301c82fd0f2dc78e86f28e47cfa5b9e02a907bb1bbf81bb
|
7
|
+
data.tar.gz: 60cc023e5660fe2e741524d1f85a1255ecea0b7dc685448441463737f5a53931d9aa808468e892fff4953201011c674ce011aaf5cdbe59f5beb91240938e36e7
|
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
|
22
|
+
<img width="415" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.6.2/core/average-speeds.png"><img width="415" alt="Chart showing compression of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.6.2/core/average-sizes.png">
|
23
23
|
|
24
|
-
|
24
|
+
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
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.2-linux-x86_64) |
|
36
|
+
[Linux ARM](https://wilsonl.in/minify-html/bin/0.6.2-linux-arm64) |
|
37
|
+
[macOS](https://wilsonl.in/minify-html/bin/0.6.2-macos-x86_64) |
|
38
|
+
[Windows](https://wilsonl.in/minify-html/bin/0.6.2-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.2", 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.2</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.2
|
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: {}
|