minify_html 0.4.10 → 0.5.3

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: b7de76d47e0e4e0ac35002de201ef5ca5ec7f1b480337b05b206c0bfea698b03
4
- data.tar.gz: 3d9403b8d46e3db7a1f415fe5d8c8a33f38e1adc925d3ff497817d271b344450
3
+ metadata.gz: fe44dec92cf8a9e85f6dba0eb13b538b1285d3556acb326cdc1aa2e7e489e6db
4
+ data.tar.gz: 68880213ec34e8a622e888c7dc9957c545917cc2483248c5646806edeb3d1d0f
5
5
  SHA512:
6
- metadata.gz: c3a2685174d50b9bfb0df312cbd0c67014576021378017837894886c6fab9f200d6f9b8fa6309e1443ec55cbe85fa983d1a01e8edf7936d01cfa8c469e07b24d
7
- data.tar.gz: 53df828a1fd29ce070a877fad34ce550d01b86d53475b99e3af2c26607ce967170a09b35a0e17bb8bce319e908e4db497818c4f55b07713086f256d069161cfd
6
+ metadata.gz: 78ca8e47a55eb6a2b05ca8446e301cf30cde354c825b37e8af7aa2dc385c5f2214509b947543dc7acb3003bb1873844d8ad18f1f0a06e7c309b4c3c90025e246
7
+ data.tar.gz: 6bee087ce415391cef7236bfa55fbeff4f691e614e2e1fdef90a41ae53039ecbf40163c92203192ad420a8ccb2b081eedd2b08482057b0f2b42bebae0783ae4c
data/README.md CHANGED
@@ -1,32 +1,42 @@
1
- # minify-html
2
-
3
- An HTML minifier meticulously optimised for both speed and effectiveness written in Rust.
4
- Comes with native bindings to Node.js, Python, Java, and Ruby.
5
-
6
- - Advanced minification strategy beats other minifiers with only one pass.
7
- - Uses zero memory allocations, SIMD searching, direct tries, and lookup tables.
8
- - Well tested with a large test suite and extensive [fuzzing](./fuzz).
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 of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.4.10/core/average-speeds.png"> <img width="415" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.4.10/core/average-sizes.png">
22
+ <img width="415" alt="Chart showing speed and compression of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.5.3/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
- ### CLI
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
- ##### Get
33
+ ### Get
24
34
 
25
- [Linux](https://wilsonl.in/minify-html/bin/0.4.10-linux-x86_64) |
26
- [macOS](https://wilsonl.in/minify-html/bin/0.4.10-macos-x86_64) |
27
- [Windows](https://wilsonl.in/minify-html/bin/0.4.10-windows-x86_64.exe)
35
+ [Linux](https://wilsonl.in/minify-html/bin/0.5.3-linux-x86_64) |
36
+ [macOS](https://wilsonl.in/minify-html/bin/0.5.3-macos-x86_64) |
37
+ [Windows](https://wilsonl.in/minify-html/bin/0.5.3-windows-x86_64.exe)
28
38
 
29
- ##### Use
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
- ### API
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
- ##### Get
52
+ ### Get
43
53
 
44
54
  ```toml
45
55
  [dependencies]
46
- minify-html = { version = "0.4.10", features = ["js-esbuild"] }
56
+ minify-html = { version = "0.5.3", 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
- ##### Use
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
- ##### Get
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
- ##### Use
90
+ ### Use
81
91
 
82
92
  ```js
83
93
  const minifyHtml = require("@minify-html/js");
84
94
 
85
- const cfg = minifyHtml.createConfiguration({ minifyJs: false, minifyCss: false });
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({ minifyJs: false, minifyCss: false });
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
- ##### Get
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.4.10</version>
127
+ <version>0.5.3</version>
124
128
  </dependency>
125
129
  ```
126
130
 
127
- ##### Use
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
- try {
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
- ##### Get
155
+ ### Get
160
156
 
161
157
  Add the PyPI project as a dependency and install it using `pip` or `pipenv`.
162
158
 
163
- ##### Use
159
+ ### Use
164
160
 
165
161
  ```python
166
162
  import minify_html
167
163
 
168
- try:
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
- ##### Get
176
+ ### Get
184
177
 
185
178
  Add the library as a dependency to `Gemfile` or `*.gemspec`.
186
179
 
187
- ##### Use
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 many 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.
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. `&&#97;&#109;&#112;;` becomes `&ampamp;`. This is done as `&amp` 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
- - Input must be UTF-8.
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.10
4
+ version: 0.5.3
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-04-16 00:00:00.000000000 Z
11
+ date: 2021-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fiddle