minify_html 0.8.0 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81ae7ec50b5dbf21e6dc97f6740fe4cfeeff1a0b80e5fa6a93b0d8f876f2fcbf
4
- data.tar.gz: 06e03a4a8303dc4e6bcddec30882dcf632936af89fd5f21388584ac5e62d2235
3
+ metadata.gz: ad0c0aff3910e52cb43003bc255c93ad18d700ede1bd93f16282fedf58ec9970
4
+ data.tar.gz: 9b8b32ee8d660a6bfab711b2066398665595fbf929b7a0d46440852ab3d55200
5
5
  SHA512:
6
- metadata.gz: c3a07a695f12a25ece4ac858a6155c55ece55ee6d888df131535660d84b97bf2e3c6c5e46c1a9f4325569e1678a766f38299be32169cb645310198fbb153b2cf
7
- data.tar.gz: 4efb0a9b2e8cbc6559f149269000efa23e781d2f2fb386206cf48d92b8ee4f9e37938c317a069ad22080f09773839bea6b5b4d2ab43c1c2edb9cbf98d11ef5a3
6
+ metadata.gz: c183bc235f0be67a05e84695e0919553f7cec9fa7d1e9f36740e2c0e2257c7b5ea779f4fa768e8dfa59b43b2d68ef32da9cc6b62982374f8aae50b6f49e9ddff
7
+ data.tar.gz: 1867c737b1bc395799778bd58a39f5cf98f8b54ce19be0f91b5ca3d58ce751d802c068626430939e08cdfd9dff5dc11e0f317acfc4d8f4e1f85259f3df95467c
data/README.md CHANGED
@@ -1,11 +1,13 @@
1
1
  <h1>
2
2
  minify-html
3
3
  <img width="24" src="https://wilsonl.in/minify-html/icon/cli.png">
4
+ <img width="24" src="https://wilsonl.in/minify-html/icon/deno.png">
4
5
  <img width="24" src="https://wilsonl.in/minify-html/icon/java.png">
5
6
  <img width="24" src="https://wilsonl.in/minify-html/icon/nodejs.png">
6
7
  <img width="24" src="https://wilsonl.in/minify-html/icon/python.png">
7
8
  <img width="24" src="https://wilsonl.in/minify-html/icon/ruby.png">
8
9
  <img width="24" src="https://wilsonl.in/minify-html/icon/rust.png">
10
+ <img width="24" src="https://wilsonl.in/minify-html/icon/wasm.png">
9
11
  </h1>
10
12
 
11
13
  A Rust HTML minifier meticulously optimised for speed and effectiveness, with bindings for other languages.
@@ -13,13 +15,15 @@ A Rust HTML minifier meticulously optimised for speed and effectiveness, with bi
13
15
  - Advanced minification strategy beats other minifiers while being much faster.
14
16
  - Uses SIMD searching, direct tries, and lookup tables.
15
17
  - Handles [invalid HTML](./notes/Parsing.md), with extensive testing and [fuzzing](./fuzz).
16
- - Natively binds to [esbuild](https://github.com/wilsonzlin/esbuild-rs) for super fast JS and CSS minification.
18
+ - Uses [minify-js](https://github.com/wilsonzlin/minify-js) for super fast JS minification.
19
+
20
+ View the [changelog](./CHANGELOG.md) to see the latest updates.
17
21
 
18
22
  ## Performance
19
23
 
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)
24
+ Comparison with [html-minifier](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
25
 
22
- <img width="400" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.8.0/core/average-speeds.png"><img width="400" alt="Chart showing compression of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.8.0/core/average-sizes.png">
26
+ <img width="400" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.9.1/core/average-speeds.png"><img width="400" alt="Chart showing compression of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.9.1/core/average-sizes.png">
23
27
 
24
28
  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
29
 
@@ -32,11 +36,11 @@ Precompiled binaries are available for Linux, macOS, and Windows.
32
36
 
33
37
  ### Get
34
38
 
35
- [Linux x64](https://wilsonl.in/minify-html/bin/0.8.0-linux-x86_64) |
36
- [Linux ARM64](https://wilsonl.in/minify-html/bin/0.8.0-linux-arm64) |
37
- [macOS x64](https://wilsonl.in/minify-html/bin/0.8.0-macos-x86_64) |
38
- [macOS ARM64](https://wilsonl.in/minify-html/bin/0.8.0-macos-arm64) |
39
- [Windows x64](https://wilsonl.in/minify-html/bin/0.8.0-windows-x86_64.exe)
39
+ [Linux x64](https://wilsonl.in/minify-html/bin/0.9.1-linux-x86_64) |
40
+ [Linux ARM64](https://wilsonl.in/minify-html/bin/0.9.1-linux-arm64) |
41
+ [macOS x64](https://wilsonl.in/minify-html/bin/0.9.1-macos-x86_64) |
42
+ [macOS ARM64](https://wilsonl.in/minify-html/bin/0.9.1-macos-arm64) |
43
+ [Windows x64](https://wilsonl.in/minify-html/bin/0.9.1-windows-x86_64.exe)
40
44
 
41
45
  ### Use
42
46
 
@@ -55,24 +59,44 @@ minify-html --output /path/to/output.min.html --keep-closing-tags --minify-css /
55
59
 
56
60
  ```toml
57
61
  [dependencies]
58
- minify-html = { version = "0.8.0", features = ["js-esbuild"] }
62
+ minify-html = { version = "0.9.1" }
59
63
  ```
60
64
 
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).
65
+ ### Use
66
+
67
+ Check out the [docs](https://docs.rs/minify-html) for API and usage examples.
68
+
69
+ </details>
70
+
71
+ <details>
72
+ <summary><img width="24" src="https://wilsonl.in/minify-html/icon/deno.png"> <strong>Deno</strong></summary>
62
73
 
63
- If the `js-esbuild` feature is not enabled, `cfg.minify_js` and `cfg.minify_css` will have no effect.
74
+ - Package: https://wilsonl.in/minify-html/deno/0.9.1/index.js
75
+ - Binding: [WASM](https://webassembly.org/)
76
+ - Platforms: All
64
77
 
65
78
  ### Use
66
79
 
67
- Check out the [docs](https://docs.rs/minify-html) for API and usage examples.
80
+ ```ts
81
+ import init, {minify} from "https://wilsonl.in/minify-html/deno/0.9.1/index.js";
82
+
83
+ const encoder = new TextEncoder();
84
+ const decoder = new TextDecoder();
85
+
86
+ await init();
87
+
88
+ const minified = decoder.decode(minify(encoder.encode("<p> Hello, world! </p>"), { keep_spaces_between_attributes: true, keep_comments: true }));
89
+ ```
90
+
91
+ All [`Cfg` fields](https://docs.rs/minify-html/latest/minify_html/struct.Cfg.html) are available as snake_case properties on the object provided as the second argument; if any are not set, they default to `false`.
68
92
 
69
93
  </details>
70
94
 
71
95
  <details>
72
96
  <summary><img width="24" src="https://wilsonl.in/minify-html/icon/nodejs.png"> <strong>Node.js</strong></summary>
73
97
 
74
- - Package: [@minify-html/js](https://www.npmjs.com/package/@minify-html/js)
75
- - Binding: [N-API](https://nodejs.org/api/n-api.html)
98
+ - Package: [@minify-html/node](https://www.npmjs.com/package/@minify-html/node)
99
+ - Binding: [Neon](https://github.com/neon-bindings/neon)
76
100
  - Platforms: Linux (ARM64 and x64), macOS (ARM64 and x64), Windows (x64); Node.js 8.6.0 and higher
77
101
 
78
102
  ### Get
@@ -80,13 +104,13 @@ Check out the [docs](https://docs.rs/minify-html) for API and usage examples.
80
104
  Using npm:
81
105
 
82
106
  ```bash
83
- npm i @minify-html/js
107
+ npm i @minify-html/node
84
108
  ```
85
109
 
86
110
  Using Yarn:
87
111
 
88
112
  ```bash
89
- yarn add @minify-html/js
113
+ yarn add @minify-html/node
90
114
  ```
91
115
 
92
116
  ### Use
@@ -94,14 +118,13 @@ yarn add @minify-html/js
94
118
  TypeScript definitions are available.
95
119
 
96
120
  ```ts
97
- import * as minifyHtml from "@minify-html/js";
98
- // Or `const minifyHtml = require("@minify-html/js")` if not using TS/ESM.
121
+ import * as minifyHtml from "@minify-html/node";
122
+ // Or `const minifyHtml = require("@minify-html/node")` if not using TS/ESM.
99
123
 
100
- const cfg = minifyHtml.createConfiguration({ keep_spaces_between_attributes: true, keep_comments: true });
101
- const minified = minifyHtml.minify("<p> Hello, world! </p>", cfg);
124
+ const minified = minifyHtml.minify("<p> Hello, world! </p>", { keep_spaces_between_attributes: true, keep_comments: true });
102
125
  ```
103
126
 
104
- All [`Cfg` fields](https://docs.rs/minify-html/latest/minify_html/struct.Cfg.html) are available as snake_case properties on the object provided to `createConfiguration`; if any are not set, they default to `false`.
127
+ All [`Cfg` fields](https://docs.rs/minify-html/latest/minify_html/struct.Cfg.html) are available as snake_case properties on the object provided as the second argument; if any are not set, they default to `false`.
105
128
 
106
129
  </details>
107
130
 
@@ -120,7 +143,7 @@ Add as a Maven dependency:
120
143
  <dependency>
121
144
  <groupId>in.wilsonl.minifyhtml</groupId>
122
145
  <artifactId>minify-html</artifactId>
123
- <version>0.8.0</version>
146
+ <version>0.9.1</version>
124
147
  </dependency>
125
148
  ```
126
149
 
@@ -188,9 +211,39 @@ All [`Cfg` fields](https://docs.rs/minify-html/latest/minify_html/struct.Cfg.htm
188
211
 
189
212
  </details>
190
213
 
214
+ <details>
215
+ <summary><img width="24" src="https://wilsonl.in/minify-html/icon/wasm.png"> <strong>WASM</strong></summary>
216
+
217
+ - Package: [@minify-html/wasm](https://npmjs.org/package/@minify-html/wasm)
218
+ - Binding: [WASM](https://webassembly.org/)
219
+ - Platforms: All
220
+
221
+ A bundler may be required to use the WebAssembly module, see [this](https://rustwasm.github.io/wasm-bindgen/reference/deployment.html#bundlers) for more details.
222
+
223
+ ### Use
224
+
225
+ ```ts
226
+ import init, {minify} from "@minify-html/wasm";
227
+
228
+ const encoder = new TextEncoder();
229
+ const decoder = new TextDecoder();
230
+
231
+ await init();
232
+
233
+ const minified = decoder.decode(minify(encoder.encode("<p> Hello, world! </p>"), { keep_spaces_between_attributes: true, keep_comments: true }));
234
+ ```
235
+
236
+ All [`Cfg` fields](https://docs.rs/minify-html/latest/minify_html/struct.Cfg.html) are available as snake_case properties on the object provided as the second argument; if any are not set, they default to `false`.
237
+
238
+ </details>
239
+
191
240
  ## Minification
192
241
 
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.
242
+ 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. To prevent this, refer to these configuration options:
243
+
244
+ - `do_not_minify_doctype`
245
+ - `ensure_spec_compliant_unquoted_attribute_values`
246
+ - `keep_spaces_between_attributes`
194
247
 
195
248
  ### Whitespace
196
249
 
@@ -292,10 +345,10 @@ minify-html assumes HTML and SVG elements are used in specific ways, based on st
292
345
 
293
346
  |Group|Elements|Expected children|
294
347
  |---|---|---|
295
- |Formatting|`a`, `strong`, [and others](./src/spec/tag/whitespace.rs)|Formatting elements, text.|
296
- |Content|`h1`, `p`, [and others](src/spec/tag/whitespace.rs)|Formatting elements, text.|
297
- |Layout|`div`, `ul`, [and others](./src/spec/tag/whitespace.rs)|Layout elements, content elements.|
298
- |Content-first|`label`, `li`, [and others](./src/spec/tag/whitespace.rs)|Like content but could be layout with only one child.|
348
+ |Formatting|`a`, `strong`, [and others](./rust/common/spec/tag/whitespace.rs)|Formatting elements, text.|
349
+ |Content|`h1`, `p`, [and others](rust/common/spec/tag/whitespace.rs)|Formatting elements, text.|
350
+ |Layout|`div`, `ul`, [and others](./rust/common/spec/tag/whitespace.rs)|Layout elements, content elements.|
351
+ |Content-first|`label`, `li`, [and others](./rust/common/spec/tag/whitespace.rs)|Like content but could be layout with only one child.|
299
352
 
300
353
  <details>
301
354
  <summary><strong>Formatting elements</strong></summary>
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.8.0
4
+ version: 0.9.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-12-15 00:00:00.000000000 Z
11
+ date: 2022-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fiddle