minify_html 0.2.5 → 0.3.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: 9e8c15c45061862bc53a2f8b0c533162a7c01fc431265dcd96304c5b693e3413
4
- data.tar.gz: 96ae5973cece926b066e04849e3d3a79e72ad9d32abf43cb4564a8daee987cb0
3
+ metadata.gz: b00d960a09c6d4de6681e685eb99b36d696cb8858b18a0654fabedf80b382a69
4
+ data.tar.gz: bcc1185949fccb475dcc7635a9426d54b4f7edff5cb3a27cae824c6da456dc68
5
5
  SHA512:
6
- metadata.gz: c3bbc7c6adcd0a5f434c210e22f8c61d1c0a112bc66cea15a5987feabb78c7f1486cb25b8da5db4763ae93db302bd6979eb4dae00ed598fab29438c138898dd7
7
- data.tar.gz: c97c0610c695c66622ab5e03ee56de1aa69e37dd9ef7f9731d030d7ba379bf6232e714a11380311684056c71ee3c5aee61250cca5a19f5927fa2da32129a8bcb
6
+ metadata.gz: aa9f76653e9059242cb57d4dba063c108ea9d710d465b1196f21e578c7a6c2b321b8c23fa9fc068eee5f3a9710be069bbe3d2722040469dcda49a9742a2240dc
7
+ data.tar.gz: e600314828a8b2a0f29a4412fbc4cf7e3fcceb4c22b842019f4f638a16e76e5d8fa3da2bb6700cc04e76cf1cd2dceb336500f0bfb324eb73c6384ec1e99e4bca
data/README.md CHANGED
@@ -1,37 +1,29 @@
1
1
  # minify-html
2
2
 
3
- A fast one-pass in-place HTML minifier written in Rust with context-aware whitespace handling.
3
+ An HTML minifier meticulously optimised for both speed and effectiveness, available for Rust, Node.js, Python, Java, and Ruby.
4
4
 
5
- Also supports JS minification by plugging into [esbuild](https://github.com/evanw/esbuild).
6
-
7
- Available as:
8
- - CLI for macOS and Linux.
9
- - Rust library.
10
- - Native library for Node.js, Python, Java, and Ruby.
11
-
12
- ## Features
13
-
14
- - Minification is done in one pass with no backtracking or DOM/AST building.
15
- - No extra heap memory is allocated during processing, which increases performance.
16
- - Context-aware whitespace handling allows maximum minification while retaining desired spaces.
5
+ - Advanced minification strategy beats other minifiers with only one pass.
6
+ - Uses zero memory allocations, SIMD searching, direct tries, and lookup tables.
17
7
  - Well tested with a large test suite and extensive [fuzzing](./fuzz).
8
+ - Natively binds to [esbuild](https://github.com/wilsonzlin/esbuild-rs) for super fast JS minification.
18
9
 
19
10
  ## Performance
20
11
 
21
- Speed and effectiveness of Node.js version compared to [html-minfier](https://github.com/kangax/html-minifier) and [minimize](https://github.com/Swaagie/minimize), run on popular already-minified web pages. See [bench](./bench) folder for more details.
12
+ 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)
22
13
 
23
- <img width="435" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.2.5/average-speeds.png"> <img width="435" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.2.5/average-sizes.png">
14
+ <img width="415" alt="Chart showing speed of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.3.3/js/average-speeds.png"> <img width="415" alt="Chart showing effectiveness of HTML minifiers" src="https://wilsonl.in/minify-html/bench/0.3.3/js/average-sizes.png">
24
15
 
25
16
  ## Usage
26
17
 
27
18
  ### CLI
28
19
 
29
- Precompiled binaries are available for x86-64 macOS and Linux.
20
+ Precompiled binaries are available for x86-64 Linux, macOS, and Windows.
30
21
 
31
22
  ##### Get
32
23
 
33
- [macOS](https://wilsonl.in/minify-html/bin/0.2.5-macos-x86_64) |
34
- [Linux](https://wilsonl.in/minify-html/bin/0.2.5-linux-x86_64)
24
+ [Linux](https://wilsonl.in/minify-html/bin/0.3.3-linux-x86_64) |
25
+ [macOS](https://wilsonl.in/minify-html/bin/0.3.3-macos-x86_64) |
26
+ [Windows](https://wilsonl.in/minify-html/bin/0.3.3-windows-x86_64.exe)
35
27
 
36
28
  ##### Use
37
29
 
@@ -50,7 +42,7 @@ minify-html --src /path/to/src.html --out /path/to/output.min.html
50
42
 
51
43
  ```toml
52
44
  [dependencies]
53
- minify-html = { version = "0.2.5", features = ["js-esbuild"] }
45
+ minify-html = { version = "0.3.3", features = ["js-esbuild"] }
54
46
  ```
55
47
 
56
48
  Building with the `js-esbuild` feature requires the Go compiler to be installed as well, to build the [JS minifier](https://github.com/evanw/esbuild).
@@ -60,7 +52,7 @@ If the `js-esbuild` feature is not enabled, `cfg.minify_js` will have no effect.
60
52
  ##### Use
61
53
 
62
54
  ```rust
63
- use minify_html::{Cfg, FriendlyError, in_place, copy, with_friendly_error, truncate};
55
+ use minify_html::{Cfg, Error, FriendlyError, in_place, copy, with_friendly_error, truncate};
64
56
 
65
57
  fn main() {
66
58
  let mut code = b"<p> Hello, world! </p>".to_vec();
@@ -72,21 +64,21 @@ fn main() {
72
64
  // but leaves any original code after the minified code intact.
73
65
  match in_place(&mut code, cfg) {
74
66
  Ok(minified_len) => {}
75
- Err((error_type, error_position)) => {}
67
+ Err(Error { error_type, position }) => {}
76
68
  };
77
69
 
78
70
  // Creates a vector copy containing only minified code
79
71
  // instead of minifying in-place.
80
72
  match copy(&code, cfg) {
81
73
  Ok(minified) => {}
82
- Err((error_type, error_position)) => {}
74
+ Err(Error { error_type, position }) => {}
83
75
  };
84
76
 
85
77
  // Minifies a vector in-place, and then truncates the
86
78
  // vector to the new minified length.
87
79
  match truncate(&mut code, cfg) {
88
80
  Ok(()) => {}
89
- Err((error_type, error_position)) => {}
81
+ Err(Error { error_type, position }) => {}
90
82
  };
91
83
 
92
84
  // Identical to `in_place` except with FriendlyError instead.
@@ -108,46 +100,48 @@ fn main() {
108
100
  <details>
109
101
  <summary><strong>Node.js</strong></summary>
110
102
 
111
- Package: [@minify-html/js-esbuild](https://www.npmjs.com/package/@minify-html/js-esbuild),
112
- Binding: [Neon](https://neon-bindings.com/)
113
- Platforms: macOS, Linux; Node.js 8 and higher
103
+ - Package: [@minify-html/js](https://www.npmjs.com/package/@minify-html/js)
104
+ - Binding: [N-API](https://nodejs.org/api/n-api.html)
105
+ - Platforms: Linux, macOS, Windows; Node.js 8.6.0 and higher
114
106
 
115
107
  ##### Get
116
108
 
117
109
  Using npm:
118
110
 
119
111
  ```bash
120
- npm i @minify-html/js-esbuild
112
+ npm i @minify-html/js
121
113
  ```
122
114
 
123
115
  Using Yarn:
124
116
 
125
117
  ```bash
126
- yarn add @minify-html/js-esbuild
118
+ yarn add @minify-html/js
127
119
  ```
128
120
 
129
121
  ##### Use
130
122
 
131
123
  ```js
132
- const minifyHtml = require("@minify-html/js-esbuild");
124
+ const minifyHtml = require("@minify-html/js");
133
125
 
134
- const cfg = { minifyJs: false };
126
+ const cfg = minifyHtml.createConfiguration({ minifyJs: false });
135
127
  const minified = minifyHtml.minify("<p> Hello, world! </p>", cfg);
136
128
 
137
129
  // Alternatively, minify in place to avoid copying.
138
- const source = Buffer.from("<p> Hello, world! </p>", cfg);
139
- minifyHtml.minifyInPlace(source);
130
+ const source = Buffer.from("<p> Hello, world! </p>");
131
+ // This is a Buffer representing a slice of `source`, not newly allocated memory.
132
+ const minified = minifyHtml.minifyInPlace(source, cfg);
140
133
  ```
141
134
 
142
135
  minify-html is also available for TypeScript:
143
136
 
144
137
  ```ts
145
- import * as minifyHtml from "@minify-html/js-esbuild";
138
+ import * as minifyHtml from "@minify-html/js";
146
139
  import * as fs from "fs";
147
140
 
148
- const cfg = { minifyJs: false };
141
+ const cfg = minifyHtml.createConfiguration({ minifyJs: false });
149
142
  const minified = minifyHtml.minify("<p> Hello, world! </p>", cfg);
150
- minifyHtml.minifyInPlace(fs.readFileSync("source.html"), cfg);
143
+ // Or alternatively:
144
+ const minified = minifyHtml.minifyInPlace(fs.readFileSync("source.html"), cfg);
151
145
  ```
152
146
 
153
147
  </details>
@@ -155,9 +149,9 @@ minifyHtml.minifyInPlace(fs.readFileSync("source.html"), cfg);
155
149
  <details>
156
150
  <summary><strong>Java</strong></summary>
157
151
 
158
- Package: [in.wilsonl.minifyhtml](https://search.maven.org/artifact/in.wilsonl.minifyhtml/minify-html)
159
- Binding: [JNI](https://github.com/jni-rs/jni-rs)
160
- Platforms: macOS, Linux; Java 7 and higher
152
+ - Package: [in.wilsonl.minifyhtml](https://search.maven.org/artifact/in.wilsonl.minifyhtml/minify-html)
153
+ - Binding: [JNI](https://github.com/jni-rs/jni-rs)
154
+ - Platforms: Linux, macOS, Windows; Java 7 and higher
161
155
 
162
156
  ##### Get
163
157
 
@@ -167,14 +161,14 @@ Add as a Maven dependency:
167
161
  <dependency>
168
162
  <groupId>in.wilsonl.minifyhtml</groupId>
169
163
  <artifactId>minify-html</artifactId>
170
- <version>0.2.5</version>
164
+ <version>0.3.3</version>
171
165
  </dependency>
172
166
  ```
173
167
 
174
168
  ##### Use
175
169
 
176
170
  ```java
177
- import in.wilsonl.minify_html.MinifyHtml;
171
+ import in.wilsonl.minifyhtml.MinifyHtml;
178
172
 
179
173
  MinifyHtml.Configuration cfg = new MinifyHtml.Configuration.Builder()
180
174
  .setMinifyJs(false)
@@ -195,9 +189,9 @@ MinifyHtml.minifyInPlace(source, cfg);
195
189
  <details>
196
190
  <summary><strong>Python</strong></summary>
197
191
 
198
- Package: [minify_html](https://pypi.org/project/minify_html)
199
- Binding: [PyO3](https://github.com/PyO3/pyo3)
200
- Platforms: macOS, Linux; CPython 3.5 and higher
192
+ - Package: [minify-html](https://pypi.org/project/minify-html)
193
+ - Binding: [PyO3](https://github.com/PyO3/pyo3)
194
+ - Platforms: Linux, macOS, Windows; Python 3.5 and higher
201
195
 
202
196
  ##### Get
203
197
 
@@ -219,9 +213,9 @@ except SyntaxError as e:
219
213
  <details>
220
214
  <summary><strong>Ruby</strong></summary>
221
215
 
222
- Package: [minify_html](https://rubygems.org/gems/minify_html)
223
- Binding: [Rutie](https://github.com/danielpclark/rutie)
224
- Platforms: macOS, Linux; Ruby 2.5 and higher
216
+ - Package: [minify_html](https://rubygems.org/gems/minify_html)
217
+ - Binding: [Rutie](https://github.com/danielpclark/rutie)
218
+ - Platforms: Linux, macOS; Ruby 2.5 and higher
225
219
 
226
220
  ##### Get
227
221
 
@@ -455,6 +449,7 @@ Spaces are removed between attributes if possible.
455
449
  ### Entities
456
450
 
457
451
  Entities are decoded if valid (see relevant parsing section) and their decoded characters as UTF-8 is shorter or equal in length.
452
+ Some entities are longer decoded than encoded, so they're left encoded.
458
453
 
459
454
  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).
460
455
 
Binary file
Binary file
Binary file
Binary file
Binary file
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.2.5
4
+ version: 0.3.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: 2020-07-11 00:00:00.000000000 Z
11
+ date: 2020-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fiddle
@@ -62,5 +62,5 @@ rubyforge_project:
62
62
  rubygems_version: 2.7.6.2
63
63
  signing_key:
64
64
  specification_version: 4
65
- summary: Fast allocation-less HTML minifier with smart whitespace handling
65
+ summary: Fast and smart HTML + JS minifier
66
66
  test_files: []