minify_html 0.4.11 → 0.5.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 +52 -63
- 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: b345a814633290c8d04adfd8c4092cd57a2ebf620917b034a2bfb53ff290daa9
|
4
|
+
data.tar.gz: f7326e86591fb55e4cf95afecb867c6176bde562ea37cee12ef3d430e22bcd33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc3b5e11f8e3815d49ee894cf3554267d225262fcc1e16065a29bd9039cb21eed907edc3f21ac2cdd8b7b2c957d9716834ef57566c5cfb0b1110c6062c22682c
|
7
|
+
data.tar.gz: 85c2986b16a7aea1b58f49719e70d687c5a4ea49a41d742969439f8ca6a5986f48b5d6a96d771c59431bde8786690b714a1c862a95b95fa5d595348b37038448
|
data/README.md
CHANGED
@@ -1,32 +1,42 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
<h1>
|
2
|
+
minify-html
|
3
|
+
<img width="24" src="./icon/cli.png">
|
4
|
+
<img width="24" src="./icon/java.png">
|
5
|
+
<img width="24" src="./icon/nodejs.png">
|
6
|
+
<img width="24" src="./icon/python.png">
|
7
|
+
<img width="24" src="./icon/ruby.png">
|
8
|
+
<img width="24" src="./icon/rust.png">
|
9
|
+
</h1>
|
10
|
+
|
11
|
+
An HTML minifier meticulously optimised for both speed and effectiveness, written in Rust.
|
12
|
+
|
13
|
+
- Advanced minification strategy beats other minifiers while being much faster.
|
14
|
+
- Uses SIMD searching, direct tries, and lookup tables.
|
15
|
+
- Handles [invalid HTML](./notes/Parsing.md), with extensive testing and [fuzzing](./fuzz).
|
9
16
|
- Natively binds to [esbuild](https://github.com/wilsonzlin/esbuild-rs) for super fast JS and CSS minification.
|
10
17
|
|
11
18
|
## Performance
|
12
19
|
|
13
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)
|
14
21
|
|
15
|
-
<img width="415" alt="Chart showing speed
|
22
|
+
<img width="415" alt="Chart showing speed and compression of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.5.0/core/average-combined.png">
|
23
|
+
|
24
|
+
Need even faster performance? Check the [one](https://github.com/wilsonzlin/minify-html/tree/one) branch.
|
16
25
|
|
17
26
|
## Usage
|
18
27
|
|
19
|
-
|
28
|
+
<details>
|
29
|
+
<summary><img width="24" src="./icon/cli.png"> <strong>CLI</strong></summary>
|
20
30
|
|
21
31
|
Precompiled binaries are available for x86-64 Linux, macOS, and Windows.
|
22
32
|
|
23
|
-
|
33
|
+
### Get
|
24
34
|
|
25
|
-
[Linux](https://wilsonl.in/minify-html/bin/0.
|
26
|
-
[macOS](https://wilsonl.in/minify-html/bin/0.
|
27
|
-
[Windows](https://wilsonl.in/minify-html/bin/0.
|
35
|
+
[Linux](https://wilsonl.in/minify-html/bin/0.5.0-linux-x86_64) |
|
36
|
+
[macOS](https://wilsonl.in/minify-html/bin/0.5.0-macos-x86_64) |
|
37
|
+
[Windows](https://wilsonl.in/minify-html/bin/0.5.0-windows-x86_64.exe)
|
28
38
|
|
29
|
-
|
39
|
+
### Use
|
30
40
|
|
31
41
|
Use the `--help` argument for more details.
|
32
42
|
|
@@ -34,36 +44,36 @@ Use the `--help` argument for more details.
|
|
34
44
|
minify-html --src /path/to/src.html --out /path/to/output.min.html --css --js
|
35
45
|
```
|
36
46
|
|
37
|
-
|
47
|
+
</details>
|
38
48
|
|
39
49
|
<details>
|
40
|
-
<summary><strong>Rust</strong></summary>
|
50
|
+
<summary><img width="24" src="./icon/rust.png"> <strong>Rust</strong></summary>
|
41
51
|
|
42
|
-
|
52
|
+
### Get
|
43
53
|
|
44
54
|
```toml
|
45
55
|
[dependencies]
|
46
|
-
minify-html = { version = "0.
|
56
|
+
minify-html = { version = "0.5.0", features = ["js-esbuild"] }
|
47
57
|
```
|
48
58
|
|
49
59
|
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).
|
50
60
|
|
51
61
|
If the `js-esbuild` feature is not enabled, `cfg.minify_js` and `cfg.minify_css` will have no effect.
|
52
62
|
|
53
|
-
|
63
|
+
### Use
|
54
64
|
|
55
65
|
Check out the [docs](https://docs.rs/minify-html) for API and usage examples.
|
56
66
|
|
57
67
|
</details>
|
58
68
|
|
59
69
|
<details>
|
60
|
-
<summary><strong>Node.js</strong></summary>
|
70
|
+
<summary><img width="24" src="./icon/nodejs.png"> <strong>Node.js</strong></summary>
|
61
71
|
|
62
72
|
- Package: [@minify-html/js](https://www.npmjs.com/package/@minify-html/js)
|
63
73
|
- Binding: [N-API](https://nodejs.org/api/n-api.html)
|
64
|
-
- Platforms: Linux, macOS, Windows; Node.js 8.6.0 and higher
|
74
|
+
- Platforms: Linux (ARM64 and x86-64), macOS (x86-64), Windows (x86-64); Node.js 8.6.0 and higher
|
65
75
|
|
66
|
-
|
76
|
+
### Get
|
67
77
|
|
68
78
|
Using npm:
|
69
79
|
|
@@ -77,18 +87,14 @@ Using Yarn:
|
|
77
87
|
yarn add @minify-html/js
|
78
88
|
```
|
79
89
|
|
80
|
-
|
90
|
+
### Use
|
81
91
|
|
82
92
|
```js
|
83
93
|
const minifyHtml = require("@minify-html/js");
|
84
94
|
|
85
|
-
|
95
|
+
// Refer to TypeScript definitions for details.
|
96
|
+
const cfg = minifyHtml.createConfiguration({ minify_js: false, minify_css: false });
|
86
97
|
const minified = minifyHtml.minify("<p> Hello, world! </p>", cfg);
|
87
|
-
|
88
|
-
// Alternatively, minify in place to avoid copying.
|
89
|
-
const source = Buffer.from("<p> Hello, world! </p>");
|
90
|
-
// This is a Buffer representing a slice of `source`, not newly allocated memory.
|
91
|
-
const minified = minifyHtml.minifyInPlace(source, cfg);
|
92
98
|
```
|
93
99
|
|
94
100
|
minify-html is also available for TypeScript:
|
@@ -97,22 +103,20 @@ minify-html is also available for TypeScript:
|
|
97
103
|
import * as minifyHtml from "@minify-html/js";
|
98
104
|
import * as fs from "fs";
|
99
105
|
|
100
|
-
const cfg = minifyHtml.createConfiguration({
|
106
|
+
const cfg = minifyHtml.createConfiguration({ minify_js: false, minify_css: false });
|
101
107
|
const minified = minifyHtml.minify("<p> Hello, world! </p>", cfg);
|
102
|
-
// Or alternatively:
|
103
|
-
const minified = minifyHtml.minifyInPlace(fs.readFileSync("source.html"), cfg);
|
104
108
|
```
|
105
109
|
|
106
110
|
</details>
|
107
111
|
|
108
112
|
<details>
|
109
|
-
<summary><strong>Java</strong></summary>
|
113
|
+
<summary><img width="24" src="./icon/java.png"> <strong>Java</strong></summary>
|
110
114
|
|
111
115
|
- Package: [in.wilsonl.minifyhtml](https://search.maven.org/artifact/in.wilsonl.minifyhtml/minify-html)
|
112
116
|
- Binding: [JNI](https://github.com/jni-rs/jni-rs)
|
113
117
|
- Platforms: Linux, macOS, Windows; Java 7 and higher
|
114
118
|
|
115
|
-
|
119
|
+
### Get
|
116
120
|
|
117
121
|
Add as a Maven dependency:
|
118
122
|
|
@@ -120,11 +124,11 @@ Add as a Maven dependency:
|
|
120
124
|
<dependency>
|
121
125
|
<groupId>in.wilsonl.minifyhtml</groupId>
|
122
126
|
<artifactId>minify-html</artifactId>
|
123
|
-
<version>0.
|
127
|
+
<version>0.5.0</version>
|
124
128
|
</dependency>
|
125
129
|
```
|
126
130
|
|
127
|
-
|
131
|
+
### Use
|
128
132
|
|
129
133
|
```java
|
130
134
|
import in.wilsonl.minifyhtml.Configuration;
|
@@ -136,55 +140,44 @@ Configuration cfg = new Configuration.Builder()
|
|
136
140
|
.setMinifyCss(false)
|
137
141
|
.build();
|
138
142
|
|
139
|
-
|
140
|
-
String minified = MinifyHtml.minify("<p> Hello, world! </p>", cfg);
|
141
|
-
} catch (SyntaxException e) {
|
142
|
-
System.err.println(e.getMessage());
|
143
|
-
}
|
144
|
-
|
145
|
-
// Alternatively, minify in place:
|
146
|
-
assert source instanceof ByteBuffer && source.isDirect();
|
147
|
-
MinifyHtml.minifyInPlace(source, cfg);
|
143
|
+
String minified = MinifyHtml.minify("<p> Hello, world! </p>", cfg);
|
148
144
|
```
|
149
145
|
|
150
146
|
</details>
|
151
147
|
|
152
148
|
<details>
|
153
|
-
<summary><strong>Python</strong></summary>
|
149
|
+
<summary><img width="24" src="./icon/python.png"> <strong>Python</strong></summary>
|
154
150
|
|
155
151
|
- Package: [minify-html](https://pypi.org/project/minify-html)
|
156
152
|
- Binding: [PyO3](https://github.com/PyO3/pyo3)
|
157
153
|
- Platforms: Linux, macOS, Windows; Python 3.7 and higher
|
158
154
|
|
159
|
-
|
155
|
+
### Get
|
160
156
|
|
161
157
|
Add the PyPI project as a dependency and install it using `pip` or `pipenv`.
|
162
158
|
|
163
|
-
|
159
|
+
### Use
|
164
160
|
|
165
161
|
```python
|
166
162
|
import minify_html
|
167
163
|
|
168
|
-
|
169
|
-
minified = minify_html.minify("<p> Hello, world! </p>", minify_js=False, minify_css=False)
|
170
|
-
except SyntaxError as e:
|
171
|
-
print(e)
|
164
|
+
minified = minify_html.minify("<p> Hello, world! </p>", minify_js=False, minify_css=False)
|
172
165
|
```
|
173
166
|
|
174
167
|
</details>
|
175
168
|
|
176
169
|
<details>
|
177
|
-
<summary><strong>Ruby</strong></summary>
|
170
|
+
<summary><img width="24" src="./icon/ruby.png"> <strong>Ruby</strong></summary>
|
178
171
|
|
179
172
|
- Package: [minify_html](https://rubygems.org/gems/minify_html)
|
180
173
|
- Binding: [Rutie](https://github.com/danielpclark/rutie)
|
181
174
|
- Platforms: Linux, macOS; Ruby 2.5 and higher
|
182
175
|
|
183
|
-
|
176
|
+
### Get
|
184
177
|
|
185
178
|
Add the library as a dependency to `Gemfile` or `*.gemspec`.
|
186
179
|
|
187
|
-
|
180
|
+
### Use
|
188
181
|
|
189
182
|
```ruby
|
190
183
|
require 'minify_html'
|
@@ -196,7 +189,7 @@ print MinifyHtml.minify("<p> Hello, world! </p>", { :minify_js => false, :mini
|
|
196
189
|
|
197
190
|
## Minification
|
198
191
|
|
199
|
-
Note that
|
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.
|
200
193
|
|
201
194
|
### Whitespace
|
202
195
|
|
@@ -413,14 +406,12 @@ Spaces are removed between attributes if possible.
|
|
413
406
|
|
414
407
|
### Entities
|
415
408
|
|
416
|
-
Entities are decoded if they're valid and shorter or equal in length when decoded.
|
409
|
+
Entities are decoded if they're valid and shorter or equal in length when decoded. UTF-8 sequences that have a shorter entity representation are encoded.
|
417
410
|
|
418
411
|
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).
|
419
412
|
|
420
413
|
If an entity is unintentionally formed after decoding, the leading ampersand is encoded, e.g. `&amp;` becomes `&amp;`. This is done as `&` is equal to or shorter than all other entity representations of characters part of an entity (`[&#a-zA-Z0-9;]`), and there is no other conflicting entity name that starts with `amp`.
|
421
414
|
|
422
|
-
Note that it's possible to get an unintentional entity after removing comments, e.g. `&am<!-- -->p`; minify-html will **not** encode the leading ampersand.
|
423
|
-
|
424
415
|
### Comments
|
425
416
|
|
426
417
|
Comments are removed.
|
@@ -431,9 +422,7 @@ Bangs, [processing instructions](https://en.wikipedia.org/wiki/Processing_Instru
|
|
431
422
|
|
432
423
|
## Parsing
|
433
424
|
|
434
|
-
-
|
435
|
-
- Opening tags must not be [omitted](https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission).
|
436
|
-
- [Escaped and double-escaped](./notes/Script%20data.md) script content are not supported.
|
425
|
+
minify-html can process any HTML, handling all possible syntax (including invalid ones) gracefully like browsers. See [Parsing.md](./notes/Parsing.md) for more details.
|
437
426
|
|
438
427
|
## Issues and contributions
|
439
428
|
|
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.5.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-
|
11
|
+
date: 2021-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fiddle
|