minify_html 0.5.3 → 0.6.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: fe44dec92cf8a9e85f6dba0eb13b538b1285d3556acb326cdc1aa2e7e489e6db
4
- data.tar.gz: 68880213ec34e8a622e888c7dc9957c545917cc2483248c5646806edeb3d1d0f
3
+ metadata.gz: 41706eaba772b31cb940330b99277dfaa2e817cd23aabf81032dd13856749753
4
+ data.tar.gz: b884392baa9e2907bef8c66b6601cd2866811e39930b2530f0c208ee8c3fe009
5
5
  SHA512:
6
- metadata.gz: 78ca8e47a55eb6a2b05ca8446e301cf30cde354c825b37e8af7aa2dc385c5f2214509b947543dc7acb3003bb1873844d8ad18f1f0a06e7c309b4c3c90025e246
7
- data.tar.gz: 6bee087ce415391cef7236bfa55fbeff4f691e614e2e1fdef90a41ae53039ecbf40163c92203192ad420a8ccb2b081eedd2b08482057b0f2b42bebae0783ae4c
6
+ metadata.gz: d231e96cfeb106eb2d26b714f9e11a81aa7ade04c28501113b3ae5abc5d178f936acd63e31d0a0048ca85a704b3d43a6b2bb52e084e41fef4a4d0594bd715dc6
7
+ data.tar.gz: 47197b32addb6004768af13147068262963e1874ccd87ad8b839f5c78f82c689743e18725e3be455e942460af69b0549ec40e279de40944104af59fb159d17aa
data/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  <h1>
2
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">
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
- An HTML minifier meticulously optimised for both speed and effectiveness, written in Rust.
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.5.3/core/average-combined.png">
22
+ <img width="415" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.6.3/core/average-speeds.png"><img width="415" alt="Chart showing compression of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.6.3/core/average-sizes.png">
23
23
 
24
- Need even faster performance? Check the [one](https://github.com/wilsonzlin/minify-html/tree/one) branch.
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="./icon/cli.png"> <strong>CLI</strong></summary>
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 x86-64 Linux, macOS, and Windows.
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.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)
35
+ [Linux x86-64](https://wilsonl.in/minify-html/bin/0.6.3-linux-x86_64) |
36
+ [Linux ARM](https://wilsonl.in/minify-html/bin/0.6.3-linux-arm64) |
37
+ [macOS](https://wilsonl.in/minify-html/bin/0.6.3-macos-x86_64) |
38
+ [Windows](https://wilsonl.in/minify-html/bin/0.6.3-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 --src /path/to/src.html --out /path/to/output.min.html --css --js
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="./icon/rust.png"> <strong>Rust</strong></summary>
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.5.3", features = ["js-esbuild"] }
57
+ minify-html = { version = "0.6.3", 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="./icon/nodejs.png"> <strong>Node.js</strong></summary>
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({ minify_js: false, minify_css: false });
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({ minify_js: false, minify_css: false });
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="./icon/java.png"> <strong>Java</strong></summary>
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.5.3</version>
128
+ <version>0.6.3</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
- .setMinifyJs(false)
140
- .setMinifyCss(false)
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="./icon/python.png"> <strong>Python</strong></summary>
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=False, minify_css=False)
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="./icon/ruby.png"> <strong>Ruby</strong></summary>
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>", { :minify_js => false, :minify_css => false })
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
- `class` and `d` attributes have their whitespace (after any decoding) trimmed and collapsed.
397
+ Attributes have their whitespace (after any decoding) trimmed and collapsed when possible.
397
398
 
398
- [Boolean attribute](./gen/attrs.json) values are removed.
399
- [Some other attributes](./gen/attrs.json) are completely removed if their value is empty or the default value after any processing.
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 if possible.
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
- 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`.
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.5.3
4
+ version: 0.6.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-08-07 00:00:00.000000000 Z
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/minify_html
42
+ homepage: https://github.com/wilsonzlin/minify-html
43
43
  licenses:
44
44
  - MIT
45
45
  metadata: {}