htmlnano 2.1.1 → 2.1.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.
Files changed (186) hide show
  1. package/README.md +53 -12
  2. package/dist/_modules/collapseAttributeWhitespace.d.mts +57 -0
  3. package/dist/_modules/collapseAttributeWhitespace.d.ts +57 -0
  4. package/dist/_modules/collapseAttributeWhitespace.js +296 -0
  5. package/dist/_modules/collapseAttributeWhitespace.mjs +293 -0
  6. package/dist/_modules/collapseBooleanAttributes.d.mts +60 -0
  7. package/dist/_modules/collapseBooleanAttributes.d.ts +60 -0
  8. package/dist/_modules/collapseBooleanAttributes.js +159 -0
  9. package/{lib/modules → dist/_modules}/collapseBooleanAttributes.mjs +39 -57
  10. package/dist/_modules/collapseWhitespace.d.mts +57 -0
  11. package/dist/_modules/collapseWhitespace.d.ts +57 -0
  12. package/dist/_modules/collapseWhitespace.js +172 -0
  13. package/dist/_modules/collapseWhitespace.mjs +170 -0
  14. package/dist/_modules/custom.d.mts +57 -0
  15. package/dist/_modules/custom.d.ts +57 -0
  16. package/dist/_modules/custom.js +22 -0
  17. package/dist/_modules/custom.mjs +20 -0
  18. package/dist/_modules/deduplicateAttributeValues.d.mts +56 -0
  19. package/dist/_modules/deduplicateAttributeValues.d.ts +56 -0
  20. package/dist/_modules/deduplicateAttributeValues.js +38 -0
  21. package/dist/_modules/deduplicateAttributeValues.mjs +36 -0
  22. package/dist/_modules/example.d.mts +59 -0
  23. package/dist/_modules/example.d.ts +59 -0
  24. package/dist/_modules/example.js +67 -0
  25. package/dist/_modules/example.mjs +65 -0
  26. package/dist/_modules/mergeScripts.d.mts +56 -0
  27. package/dist/_modules/mergeScripts.d.ts +56 -0
  28. package/dist/_modules/mergeScripts.js +53 -0
  29. package/dist/_modules/mergeScripts.mjs +51 -0
  30. package/dist/_modules/mergeStyles.d.mts +56 -0
  31. package/dist/_modules/mergeStyles.d.ts +56 -0
  32. package/dist/_modules/mergeStyles.js +42 -0
  33. package/dist/_modules/mergeStyles.mjs +40 -0
  34. package/dist/_modules/minifyConditionalComments.d.mts +56 -0
  35. package/dist/_modules/minifyConditionalComments.d.ts +56 -0
  36. package/dist/_modules/minifyConditionalComments.js +54 -0
  37. package/{lib/modules → dist/_modules}/minifyConditionalComments.mjs +21 -22
  38. package/dist/_modules/minifyCss.d.mts +56 -0
  39. package/dist/_modules/minifyCss.d.ts +56 -0
  40. package/dist/_modules/minifyCss.js +84 -0
  41. package/dist/_modules/minifyCss.mjs +82 -0
  42. package/dist/_modules/minifyJs.d.mts +56 -0
  43. package/dist/_modules/minifyJs.d.ts +56 -0
  44. package/dist/_modules/minifyJs.js +108 -0
  45. package/dist/_modules/minifyJs.mjs +106 -0
  46. package/dist/_modules/minifyJson.d.mts +56 -0
  47. package/dist/_modules/minifyJson.d.ts +56 -0
  48. package/dist/_modules/minifyJson.js +35 -0
  49. package/dist/_modules/minifyJson.mjs +33 -0
  50. package/dist/_modules/minifySvg.d.mts +56 -0
  51. package/dist/_modules/minifySvg.d.ts +56 -0
  52. package/dist/_modules/minifySvg.js +40 -0
  53. package/dist/_modules/minifySvg.mjs +38 -0
  54. package/dist/_modules/minifyUrls.d.mts +56 -0
  55. package/dist/_modules/minifyUrls.d.ts +56 -0
  56. package/dist/_modules/minifyUrls.js +180 -0
  57. package/dist/_modules/minifyUrls.mjs +178 -0
  58. package/dist/_modules/normalizeAttributeValues.d.mts +56 -0
  59. package/dist/_modules/normalizeAttributeValues.d.ts +56 -0
  60. package/dist/_modules/normalizeAttributeValues.js +234 -0
  61. package/dist/_modules/normalizeAttributeValues.mjs +232 -0
  62. package/dist/_modules/removeAttributeQuotes.d.mts +56 -0
  63. package/dist/_modules/removeAttributeQuotes.d.ts +56 -0
  64. package/dist/_modules/removeAttributeQuotes.js +15 -0
  65. package/dist/_modules/removeAttributeQuotes.mjs +13 -0
  66. package/dist/_modules/removeComments.d.mts +58 -0
  67. package/dist/_modules/removeComments.d.ts +58 -0
  68. package/dist/_modules/removeComments.js +83 -0
  69. package/{lib/modules → dist/_modules}/removeComments.mjs +24 -35
  70. package/dist/_modules/removeEmptyAttributes.d.mts +56 -0
  71. package/dist/_modules/removeEmptyAttributes.d.ts +56 -0
  72. package/dist/_modules/removeEmptyAttributes.js +197 -0
  73. package/dist/_modules/removeEmptyAttributes.mjs +195 -0
  74. package/dist/_modules/removeOptionalTags.d.mts +56 -0
  75. package/dist/_modules/removeOptionalTags.d.ts +56 -0
  76. package/dist/_modules/removeOptionalTags.js +190 -0
  77. package/{lib/modules → dist/_modules}/removeOptionalTags.mjs +54 -91
  78. package/dist/_modules/removeRedundantAttributes.d.mts +57 -0
  79. package/dist/_modules/removeRedundantAttributes.d.ts +57 -0
  80. package/dist/_modules/removeRedundantAttributes.js +128 -0
  81. package/{lib/modules → dist/_modules}/removeRedundantAttributes.mjs +43 -59
  82. package/dist/_modules/removeUnusedCss.d.mts +60 -0
  83. package/dist/_modules/removeUnusedCss.d.ts +60 -0
  84. package/dist/_modules/removeUnusedCss.js +134 -0
  85. package/dist/_modules/removeUnusedCss.mjs +132 -0
  86. package/dist/_modules/sortAttributes.d.mts +57 -0
  87. package/dist/_modules/sortAttributes.d.ts +57 -0
  88. package/dist/_modules/sortAttributes.js +102 -0
  89. package/{lib/modules → dist/_modules}/sortAttributes.mjs +39 -60
  90. package/dist/_modules/sortAttributesWithLists.d.mts +56 -0
  91. package/dist/_modules/sortAttributesWithLists.d.ts +56 -0
  92. package/dist/_modules/sortAttributesWithLists.js +118 -0
  93. package/{lib/modules → dist/_modules}/sortAttributesWithLists.mjs +41 -60
  94. package/dist/helpers.js +72 -0
  95. package/dist/helpers.mjs +63 -0
  96. package/dist/index.js +223 -0
  97. package/dist/index.mjs +209 -0
  98. package/dist/presets/ampSafe.js +19 -0
  99. package/{lib → dist}/presets/ampSafe.mjs +6 -4
  100. package/dist/presets/max.js +28 -0
  101. package/{lib → dist}/presets/max.mjs +6 -4
  102. package/dist/presets/safe.js +60 -0
  103. package/{lib → dist}/presets/safe.mjs +13 -20
  104. package/package.json +53 -59
  105. package/.eslintignore +0 -3
  106. package/CHANGELOG.md +0 -398
  107. package/docs/README.md +0 -33
  108. package/docs/babel.config.js +0 -3
  109. package/docs/docs/010-introduction.md +0 -22
  110. package/docs/docs/020-usage.md +0 -117
  111. package/docs/docs/030-config.md +0 -21
  112. package/docs/docs/040-presets.md +0 -75
  113. package/docs/docs/050-modules.md +0 -855
  114. package/docs/docs/060-contribute.md +0 -16
  115. package/docs/docusaurus.config.js +0 -65
  116. package/docs/netlify.toml +0 -4
  117. package/docs/package-lock.json +0 -21796
  118. package/docs/package.json +0 -40
  119. package/docs/sidebars.js +0 -26
  120. package/docs/versioned_docs/version-1.1.1/010-introduction.md +0 -22
  121. package/docs/versioned_docs/version-1.1.1/020-usage.md +0 -77
  122. package/docs/versioned_docs/version-1.1.1/030-config.md +0 -21
  123. package/docs/versioned_docs/version-1.1.1/040-presets.md +0 -75
  124. package/docs/versioned_docs/version-1.1.1/050-modules.md +0 -785
  125. package/docs/versioned_docs/version-1.1.1/060-contribute.md +0 -16
  126. package/docs/versioned_docs/version-2.0.0/010-introduction.md +0 -22
  127. package/docs/versioned_docs/version-2.0.0/020-usage.md +0 -77
  128. package/docs/versioned_docs/version-2.0.0/030-config.md +0 -21
  129. package/docs/versioned_docs/version-2.0.0/040-presets.md +0 -75
  130. package/docs/versioned_docs/version-2.0.0/050-modules.md +0 -838
  131. package/docs/versioned_docs/version-2.0.0/060-contribute.md +0 -16
  132. package/docs/versioned_sidebars/version-1.1.1-sidebars.json +0 -8
  133. package/docs/versioned_sidebars/version-2.0.0-sidebars.json +0 -8
  134. package/docs/versions.json +0 -4
  135. package/index.cjs +0 -11
  136. package/index.d.cts +0 -3
  137. package/index.d.mts +0 -3
  138. package/index.d.ts +0 -93
  139. package/index.mjs +0 -2
  140. package/lib/helpers.cjs +0 -79
  141. package/lib/helpers.mjs +0 -53
  142. package/lib/htmlnano.cjs +0 -200
  143. package/lib/htmlnano.mjs +0 -196
  144. package/lib/modules/collapseAttributeWhitespace.cjs +0 -86
  145. package/lib/modules/collapseAttributeWhitespace.mjs +0 -104
  146. package/lib/modules/collapseBooleanAttributes.cjs +0 -62
  147. package/lib/modules/collapseWhitespace.cjs +0 -100
  148. package/lib/modules/collapseWhitespace.mjs +0 -132
  149. package/lib/modules/custom.cjs +0 -19
  150. package/lib/modules/custom.mjs +0 -16
  151. package/lib/modules/deduplicateAttributeValues.cjs +0 -38
  152. package/lib/modules/deduplicateAttributeValues.mjs +0 -40
  153. package/lib/modules/example.cjs +0 -85
  154. package/lib/modules/example.mjs +0 -75
  155. package/lib/modules/mergeScripts.cjs +0 -54
  156. package/lib/modules/mergeScripts.mjs +0 -56
  157. package/lib/modules/mergeStyles.cjs +0 -38
  158. package/lib/modules/mergeStyles.mjs +0 -36
  159. package/lib/modules/minifyConditionalComments.cjs +0 -47
  160. package/lib/modules/minifyCss.cjs +0 -73
  161. package/lib/modules/minifyCss.mjs +0 -88
  162. package/lib/modules/minifyJs.cjs +0 -103
  163. package/lib/modules/minifyJs.mjs +0 -121
  164. package/lib/modules/minifyJson.cjs +0 -24
  165. package/lib/modules/minifyJson.mjs +0 -21
  166. package/lib/modules/minifySvg.cjs +0 -37
  167. package/lib/modules/minifySvg.mjs +0 -30
  168. package/lib/modules/minifyUrls.cjs +0 -141
  169. package/lib/modules/minifyUrls.mjs +0 -229
  170. package/lib/modules/normalizeAttributeValues.cjs +0 -120
  171. package/lib/modules/normalizeAttributeValues.mjs +0 -140
  172. package/lib/modules/removeAttributeQuotes.cjs +0 -17
  173. package/lib/modules/removeAttributeQuotes.mjs +0 -12
  174. package/lib/modules/removeComments.cjs +0 -86
  175. package/lib/modules/removeEmptyAttributes.cjs +0 -72
  176. package/lib/modules/removeEmptyAttributes.mjs +0 -121
  177. package/lib/modules/removeOptionalTags.cjs +0 -183
  178. package/lib/modules/removeRedundantAttributes.cjs +0 -112
  179. package/lib/modules/removeUnusedCss.cjs +0 -113
  180. package/lib/modules/removeUnusedCss.mjs +0 -122
  181. package/lib/modules/sortAttributes.cjs +0 -99
  182. package/lib/modules/sortAttributesWithLists.cjs +0 -115
  183. package/lib/presets/ampSafe.cjs +0 -18
  184. package/lib/presets/max.cjs +0 -27
  185. package/lib/presets/safe.cjs +0 -65
  186. package/test.js +0 -48
package/CHANGELOG.md DELETED
@@ -1,398 +0,0 @@
1
- # Change Log
2
- All notable changes to this project will be documented in this file.
3
- This project adheres to [Semantic Versioning](http://semver.org/).
4
-
5
- ## [2.1.1] - 2024-04-28
6
-
7
- ### Fixed
8
- - Downlevel-revealed closing comment being deleted in safe mode [#278]
9
-
10
-
11
- ## [2.1.0] - 2023-10-19
12
-
13
- ### Added
14
- - Convert htmlnano to ES Modules [#260]
15
-
16
- ### Fixed
17
- - Collapse white spaces according to specs [#257]
18
-
19
-
20
- ## [2.0.4] - 2023-04-15
21
-
22
- ### Fixed
23
- - Should not minify `<script>` and `<style>` with SRI [#220]
24
- - Should not merge `<style>` or `<script>` with SRI [#220]
25
- - Should not minify json with SRI [#220]
26
-
27
-
28
- ## [2.0.3] - 2022-11-13
29
-
30
- ### Added
31
- - Minify function for `HtmlMinimizerWebpackPlugin`
32
-
33
- ### Fixed
34
- - `collapseWhitespace`: handle textNode when comment is preserved [#184]
35
- - `minifyUrls`: srcset & javascript: url [#185]
36
- - Correct missing value default usage
37
- - `collapseBooleanAttributes`: empty string attributes
38
- - Guard type of attributes' value [#195]
39
- - Do not choke on svg error [#197]
40
-
41
- ### Changed
42
- - Minify based on invalid value default
43
- - Avoid hardcoding preset keys
44
-
45
-
46
- ## [2.0.2] - 2022-04-06
47
-
48
- ### Fixed
49
- - JSON-LD crash [#182]
50
-
51
-
52
- ## [2.0.1] - 2022-04-04
53
- **This version contains a critical bug [#182].**
54
- **Don't use it.**
55
-
56
- ### Changed
57
- - Speed improvements [#127]
58
- - Fix `<img sizes>` [#180]
59
-
60
-
61
- ## [2.0.0] - 2022-01-12
62
- *The major version has to be released because of vulnerability in PostCSS (see [#165])*
63
-
64
- ### Changed
65
- - Support optional dependencies [#168] (`minifyUrl`, ` minifyJs`, `removeUnusedCss`, `minifyCss`). *This might be a breaking change for you*. Check the docs: https://github.com/posthtml/htmlnano/pull/168/files
66
- - Disable `mergeScripts` & `mergeStyles` in the safe preset [#170].
67
-
68
-
69
- ## [1.1.1] - 2021-09-19
70
- This version fixes fatal errors introduced in [1.1.0].
71
-
72
-
73
- ## [1.1.0] - 2021-09-19
74
- *This version contains fatal errors. Please use [1.1.1] instead.*
75
-
76
- ### Added
77
- - Collapse missing value default attribute in `removeRedundantAttributes` [#158].
78
- - New `normalizeAttributeValues` module to normalize casing of attribute values [#163].
79
- - Custom matcher for `removeComments` [#156].
80
-
81
- ### Changed
82
- - Remove more empty attributes in `removeEmptyAttributes` [#161].
83
- - Enhance collapse whitespace in `collapseWhitespace` [#145].
84
- - `minifyJs` and `minifyUrls` enhancement [#159].
85
- - Enhance attribute collapse whitespace in `collapseAttributeWhitespace` [#157].
86
-
87
-
88
-
89
- ## [1.0.1] - 2021-09-11
90
- ### Added
91
- - Support of [@novaatwarren/uncss](https://github.com/novaatwarren/uncss) fork [#154]
92
-
93
- ### Changed
94
- - SVGO plugins configuration [#153]
95
-
96
-
97
-
98
- ## [1.0.0] - 2021-04-17
99
- After more than 4 years of development, it's time to release a stable [1.0.0](https://github.com/posthtml/htmlnano/releases/tag/1.0.0) version 🎉
100
-
101
- It doesn't contain anything new from the previous [0.2.9](https://github.com/posthtml/htmlnano/releases/tag/0.2.9) release.
102
- We just did a major upgrade of two dependencies: [PurgeCSS](https://purgecss.com/) and [SVGO](https://github.com/svg/svgo),
103
- which changed their config format.
104
- Thus we have to do a major release of `htmlnano`.
105
-
106
- You can safely upgrade to `htmlnano@1.0.0` if you don't pass any config to `minifySvg` or `removeUnusedCss` (while used with PurgeCSS) modules.
107
- Otherwise, you have to adapt the config according to the new [PurgeCSS@3](https://github.com/FullHuman/purgecss/releases/tag/v3.0.0) and [SVGO@2](https://github.com/svg/svgo/releases/tag/v2.0.0) config format.
108
-
109
-
110
-
111
- ## [0.2.9] - 2021-04-11
112
- ### Added
113
- - `minifyConditionalComment` support `<html>` [#125].
114
- - Minify JS within `<script type="module">` [#135].
115
-
116
- ### Fixed
117
- - `collapseWhitespaces` around comment [#120].
118
- - handle `CDATA` inside script correctly [#122].
119
- - Minify SVG correctly [#129].
120
-
121
- ### Changed
122
- - Upgrade to terser@5 (JS minification).
123
-
124
-
125
-
126
- ## [0.2.8] - 2020-11-15
127
- ### Added
128
- - [`removeOptionalTags`](https://github.com/posthtml/htmlnano#removeoptionaltags) [#110].
129
- - [`sortAttributes`](https://github.com/posthtml/htmlnano#removeoptionaltags) [#113].
130
- - `source[src]` and `srcset` support to `minifyUrls` [#117].
131
- - [`minifyConditionalComments`](https://github.com/posthtml/htmlnano#minifyconditionalcomments) [#119].
132
-
133
- ### Changed
134
- - Sort by frequency `sortAttributesWithLists` [#111].
135
- - Strip more spaces in `collapseWhitespace` [#112].
136
- - Remove `loading="eager"` from `<img>` and `<iframe>` [#114].
137
- - Remove redundant `type` from `<script>` [#114].
138
- - Strip whitespaces between textnode and element [#116].
139
-
140
-
141
-
142
- ## [0.2.7] - 2020-10-17
143
- ### Added
144
- - More aggressive whitespace removal option [#90].
145
- - Cloudflare SSE support to `removeComments` [#94].
146
- - Improve compression ratio by sorting attribute values [#95].
147
- - New `minifyUrls` module [#98].
148
- - New `removeAttributeQuotes` module [#104].
149
- - Remove `type=text/css` for `link[rel=stylesheet]` [#102].
150
- - Collapse `crossorigin` attributes [#107].
151
- - Exclude excerpt comment for common CMS [#108].
152
-
153
- ### Fixed
154
- - Keep JS inside SVG wrapped in `//<![CDATA[ //]]` [#88].
155
-
156
-
157
- ## [0.2.6] - 2020-07-15
158
- ### Added
159
- - Let PostHTML options to be passed.
160
-
161
- ### Fixed
162
- - `<script>` tags merging without content.
163
-
164
-
165
- ## [0.2.5] - 2019-11-09
166
- ### Added
167
- - Option to remove unused CSS using PurgeCSS [#84].
168
-
169
- ### Fixed
170
- - Keep the order of inline and external JS [#80].
171
-
172
-
173
- ## [0.2.4] - 2019-07-11
174
- ### Fixed
175
- - Remove crossorigin from boolean attribute [#78], [#79].
176
- - Disable SVGO plugin convertShapeToPath in safe preset [#76].
177
-
178
-
179
- ## [0.2.3] - 2019-02-14
180
- ### Fixed
181
- - Keep `<g>` in SVG by default [#71].
182
-
183
-
184
- ## [0.2.2] - 2019-01-03
185
- ### Added
186
- - `removeUnusedCss` module [#36].
187
-
188
- ### Fixed
189
- - Bug when `tag === false` [#66].
190
- - Add `crossorigin` to boolean attributes [#67].
191
-
192
-
193
- ## [0.2.1] - 2018-12-01
194
- ### Fixed
195
- - Disable JS minifying on AMP pages [#65].
196
-
197
- ## [0.2.0] - 2018-09-14
198
- ### Breaking changes
199
- - The API of `minifyCss` module has been changed since `cssnano` has been updated to version 4, which has a different API. Check the following resources for more info:
200
- * [htmlnano docs](https://github.com/posthtml/htmlnano#minifycss)
201
- * [cssnano docs](https://cssnano.co/guides/presets)
202
- * Diff of commit [979f2c](https://github.com/posthtml/htmlnano/commit/979f2c821892c9e979e8b85f74ed0394330fceaf) with the changes of related docs.
203
-
204
- ### Added
205
- - Add presets [#64].
206
- - Add `collapseAttributeWhitespace` module for collapsing spaces in list-like attributes [#25].
207
- - Add `deduplicateAttributeValues` module for de-duplicating values in list-like attributes [#39].
208
- - Better support for AMP pages [#59].
209
- - Collapse whitespaces between top-level tags [#24].
210
-
211
- ### Changed
212
- - Improve whitespace normalization using `normalize-html-whitespace` [#21].
213
-
214
- ### Fixed
215
- - Don't collapse `visible="false"` attributes in A-Frame pages [#62].
216
-
217
-
218
-
219
- ## [0.1.10] - 2018-08-03
220
- ### Fixed
221
- - Merging `<script>` tags without leading `;` [#55].
222
-
223
-
224
- ## [0.1.9] - 2018-04-29
225
- ### Fixed
226
- - Default minification options safety [#50].
227
-
228
-
229
- ## [0.1.8] - 2018-04-17
230
- ### Fixed
231
- - ES6+ minification [#48].
232
-
233
-
234
-
235
- ## [0.1.7] - 2018-03-13
236
- ### Fixed
237
- - Update dependencies which also fixes the SVG minification bug [#47].
238
-
239
-
240
-
241
- ## [0.1.6] - 2017-06-27
242
- ### Fixed
243
- - "Not a function" error [#42].
244
-
245
-
246
-
247
- ## [0.1.5] - 2016-04-24
248
- ### Added
249
- - Minify SVG [#28].
250
- - Merge `<script>` [#19].
251
-
252
- ### Changed
253
- - Remove redundant `type="submit"` from `<button>` [#31].
254
-
255
- ### Fixed
256
- - Windows build [#30].
257
-
258
-
259
- ## [0.1.4] - 2016-02-16
260
- ### Added
261
- - Minify JSON.
262
- - Merge multiple `<style>` into one.
263
- - Collapse boolean attributes.
264
- - Remove redundant attributes.
265
- - HTML minifiers benchmark [#22].
266
-
267
- ### Changed
268
- - Expand list of JSON-like mime types [#20].
269
-
270
-
271
- ## [0.1.3] - 2016-02-09
272
- ### Fixed
273
- - Don't alter HTML comments inside not relevant modules [#17].
274
-
275
-
276
- ## [0.1.2] - 2016-02-07
277
- ### Fixed
278
- - Don't remove conditional comments in safe mode [#13].
279
- - Downgrade: `String.startsWith -> String.search`.
280
-
281
-
282
- ## [0.1.1] - 2016-01-31
283
- ### Added
284
- - Minify CSS inside `<style>` tags and `style` attributes.
285
- - Minify JS inside `<script>` tags and `on*` attributes.
286
-
287
- ### Changed
288
- - Remove attributes that contains only white spaces.
289
-
290
-
291
- [2.1.1]: https://github.com/posthtml/htmlnano/compare/2.1.0...2.1.1
292
- [2.1.0]: https://github.com/posthtml/htmlnano/compare/2.0.4...2.1.0
293
- [2.0.4]: https://github.com/posthtml/htmlnano/compare/2.0.3...2.0.4
294
- [2.0.3]: https://github.com/posthtml/htmlnano/compare/2.0.2...2.0.3
295
- [2.0.2]: https://github.com/posthtml/htmlnano/compare/2.0.1...2.0.2
296
- [2.0.1]: https://github.com/posthtml/htmlnano/compare/2.0.0...2.0.1
297
- [2.0.0]: https://github.com/posthtml/htmlnano/compare/1.1.1...2.0.0
298
- [1.1.1]: https://github.com/posthtml/htmlnano/compare/1.1.0...1.1.1
299
- [1.1.0]: https://github.com/posthtml/htmlnano/compare/1.0.1...1.1.0
300
- [1.0.1]: https://github.com/posthtml/htmlnano/compare/1.0.0...1.0.1
301
- [1.0.0]: https://github.com/posthtml/htmlnano/compare/0.2.9...1.0.0
302
- [0.2.9]: https://github.com/posthtml/htmlnano/compare/0.2.8...0.2.9
303
- [0.2.8]: https://github.com/posthtml/htmlnano/compare/0.2.7...0.2.8
304
- [0.2.7]: https://github.com/posthtml/htmlnano/compare/0.2.6...0.2.7
305
- [0.2.6]: https://github.com/posthtml/htmlnano/compare/0.2.5...0.2.6
306
- [0.2.5]: https://github.com/posthtml/htmlnano/compare/0.2.4...0.2.5
307
- [0.2.4]: https://github.com/posthtml/htmlnano/compare/0.2.3...0.2.4
308
- [0.2.3]: https://github.com/posthtml/htmlnano/compare/0.2.2...0.2.3
309
- [0.2.2]: https://github.com/posthtml/htmlnano/compare/0.2.1...0.2.2
310
- [0.2.1]: https://github.com/posthtml/htmlnano/compare/0.2.0...0.2.1
311
- [0.2.0]: https://github.com/posthtml/htmlnano/compare/0.1.10...0.2.0
312
- [0.1.10]: https://github.com/posthtml/htmlnano/compare/0.1.9...0.1.10
313
- [0.1.9]: https://github.com/posthtml/htmlnano/compare/0.1.8...0.1.9
314
- [0.1.8]: https://github.com/posthtml/htmlnano/compare/0.1.7...0.1.8
315
- [0.1.7]: https://github.com/posthtml/htmlnano/compare/0.1.6...0.1.7
316
- [0.1.6]: https://github.com/posthtml/htmlnano/compare/0.1.5...0.1.6
317
- [0.1.5]: https://github.com/posthtml/htmlnano/compare/0.1.4...0.1.5
318
- [0.1.4]: https://github.com/posthtml/htmlnano/compare/0.1.3...0.1.4
319
- [0.1.3]: https://github.com/posthtml/htmlnano/compare/0.1.2...0.1.3
320
- [0.1.2]: https://github.com/posthtml/htmlnano/compare/0.1.1...0.1.2
321
- [0.1.1]: https://github.com/posthtml/htmlnano/compare/0.1.0...0.1.1
322
-
323
-
324
- [#278]: https://github.com/posthtml/htmlnano/issues/278
325
- [#260]: https://github.com/posthtml/htmlnano/issues/260
326
- [#257]: https://github.com/posthtml/htmlnano/issues/257
327
- [#220]: https://github.com/posthtml/htmlnano/issues/220
328
- [#197]: https://github.com/posthtml/htmlnano/issues/197
329
- [#195]: https://github.com/posthtml/htmlnano/issues/195
330
- [#185]: https://github.com/posthtml/htmlnano/issues/185
331
- [#184]: https://github.com/posthtml/htmlnano/issues/184
332
- [#182]: https://github.com/posthtml/htmlnano/issues/182
333
- [#180]: https://github.com/posthtml/htmlnano/issues/180
334
- [#170]: https://github.com/posthtml/htmlnano/issues/170
335
- [#168]: https://github.com/posthtml/htmlnano/issues/168
336
- [#165]: https://github.com/posthtml/htmlnano/issues/165
337
- [#163]: https://github.com/posthtml/htmlnano/issues/163
338
- [#161]: https://github.com/posthtml/htmlnano/issues/161
339
- [#159]: https://github.com/posthtml/htmlnano/issues/159
340
- [#158]: https://github.com/posthtml/htmlnano/issues/158
341
- [#157]: https://github.com/posthtml/htmlnano/issues/157
342
- [#156]: https://github.com/posthtml/htmlnano/issues/156
343
- [#154]: https://github.com/posthtml/htmlnano/issues/154
344
- [#153]: https://github.com/posthtml/htmlnano/issues/153
345
- [#145]: https://github.com/posthtml/htmlnano/issues/145
346
- [#135]: https://github.com/posthtml/htmlnano/issues/135
347
- [#129]: https://github.com/posthtml/htmlnano/issues/129
348
- [#127]: https://github.com/posthtml/htmlnano/issues/127
349
- [#125]: https://github.com/posthtml/htmlnano/issues/125
350
- [#122]: https://github.com/posthtml/htmlnano/issues/122
351
- [#120]: https://github.com/posthtml/htmlnano/issues/120
352
- [#119]: https://github.com/posthtml/htmlnano/issues/119
353
- [#117]: https://github.com/posthtml/htmlnano/issues/117
354
- [#116]: https://github.com/posthtml/htmlnano/issues/116
355
- [#114]: https://github.com/posthtml/htmlnano/issues/114
356
- [#113]: https://github.com/posthtml/htmlnano/issues/113
357
- [#112]: https://github.com/posthtml/htmlnano/issues/112
358
- [#111]: https://github.com/posthtml/htmlnano/issues/111
359
- [#110]: https://github.com/posthtml/htmlnano/issues/110
360
- [#108]: https://github.com/posthtml/htmlnano/issues/108
361
- [#107]: https://github.com/posthtml/htmlnano/issues/107
362
- [#104]: https://github.com/posthtml/htmlnano/issues/104
363
- [#102]: https://github.com/posthtml/htmlnano/issues/102
364
- [#98]: https://github.com/posthtml/htmlnano/issues/98
365
- [#95]: https://github.com/posthtml/htmlnano/issues/95
366
- [#94]: https://github.com/posthtml/htmlnano/issues/94
367
- [#90]: https://github.com/posthtml/htmlnano/issues/90
368
- [#88]: https://github.com/posthtml/htmlnano/issues/88
369
- [#84]: https://github.com/posthtml/htmlnano/issues/84
370
- [#80]: https://github.com/posthtml/htmlnano/issues/80
371
- [#79]: https://github.com/posthtml/htmlnano/issues/79
372
- [#78]: https://github.com/posthtml/htmlnano/issues/78
373
- [#76]: https://github.com/posthtml/htmlnano/issues/76
374
- [#71]: https://github.com/posthtml/htmlnano/issues/71
375
- [#67]: https://github.com/posthtml/htmlnano/issues/67
376
- [#66]: https://github.com/posthtml/htmlnano/issues/66
377
- [#65]: https://github.com/posthtml/htmlnano/issues/65
378
- [#64]: https://github.com/posthtml/htmlnano/issues/64
379
- [#62]: https://github.com/posthtml/htmlnano/issues/62
380
- [#59]: https://github.com/posthtml/htmlnano/issues/59
381
- [#55]: https://github.com/posthtml/htmlnano/issues/55
382
- [#50]: https://github.com/posthtml/htmlnano/issues/50
383
- [#48]: https://github.com/posthtml/htmlnano/issues/48
384
- [#47]: https://github.com/posthtml/htmlnano/issues/47
385
- [#42]: https://github.com/posthtml/htmlnano/issues/42
386
- [#39]: https://github.com/posthtml/htmlnano/issues/39
387
- [#36]: https://github.com/posthtml/htmlnano/issues/36
388
- [#31]: https://github.com/posthtml/htmlnano/issues/31
389
- [#30]: https://github.com/posthtml/htmlnano/issues/30
390
- [#28]: https://github.com/posthtml/htmlnano/issues/28
391
- [#25]: https://github.com/posthtml/htmlnano/issues/25
392
- [#24]: https://github.com/posthtml/htmlnano/issues/24
393
- [#22]: https://github.com/posthtml/htmlnano/issues/22
394
- [#21]: https://github.com/posthtml/htmlnano/issues/21
395
- [#20]: https://github.com/posthtml/htmlnano/issues/20
396
- [#19]: https://github.com/posthtml/htmlnano/issues/19
397
- [#17]: https://github.com/posthtml/htmlnano/issues/17
398
- [#13]: https://github.com/posthtml/htmlnano/issues/13
package/docs/README.md DELETED
@@ -1,33 +0,0 @@
1
- # Website
2
-
3
- This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.
4
-
5
- ## Installation
6
-
7
- ```console
8
- yarn install
9
- ```
10
-
11
- ## Local Development
12
-
13
- ```console
14
- yarn start
15
- ```
16
-
17
- This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
18
-
19
- ## Build
20
-
21
- ```console
22
- yarn build
23
- ```
24
-
25
- This command generates static content into the `build` directory and can be served using any static contents hosting service.
26
-
27
- ## Deployment
28
-
29
- ```console
30
- GIT_USER=<Your GitHub username> USE_SSH=true yarn deploy
31
- ```
32
-
33
- If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
3
- };
@@ -1,22 +0,0 @@
1
- ---
2
- sidebar_position: 1
3
- slug: /
4
- ---
5
-
6
- # Introduction
7
-
8
- Modular HTML minifier, built on top of the [PostHTML](https://github.com/posthtml/posthtml).
9
- Inspired by [cssnano](http://cssnano.co/).
10
-
11
-
12
- ## [Benchmark](https://github.com/maltsev/html-minifiers-benchmark/blob/master/README.md)
13
- [html-minifier-terser@5.1.1]: https://www.npmjs.com/package/html-minifier-terser
14
- [htmlnano@2.0.0]: https://www.npmjs.com/package/htmlnano
15
-
16
- | Website | Source (KB) | [html-minifier-terser@5.1.1] | [htmlnano@2.0.0] |
17
- |---------|------------:|----------------:|-----------:|
18
- | [stackoverflow.blog](https://stackoverflow.blog/) | 95 | 87 | 82 |
19
- | [github.com](https://github.com/) | 210 | 183 | 171 |
20
- | [en.wikipedia.org](https://en.wikipedia.org/wiki/Main_Page) | 78 | 72 | 72 |
21
- | [npmjs.com](https://www.npmjs.com/features) | 41 | 38 | 36 |
22
- | **Avg. minify rate** | 0% | **9%** | **13%** |
@@ -1,117 +0,0 @@
1
- # Usage
2
- ## Javascript
3
- ```js
4
- const htmlnano = require('htmlnano');
5
- const options = {
6
- removeEmptyAttributes: false, // Disable the module "removeEmptyAttributes"
7
- collapseWhitespace: 'conservative' // Pass options to the module "collapseWhitespace"
8
- };
9
- // posthtml, posthtml-render, and posthtml-parse options
10
- const postHtmlOptions = {
11
- sync: true, // https://github.com/posthtml/posthtml#usage
12
- lowerCaseTags: true, // https://github.com/posthtml/posthtml-parser#options
13
- quoteAllAttributes: false, // https://github.com/posthtml/posthtml-render#options
14
- };
15
-
16
- htmlnano
17
- // "preset" arg might be skipped (see "Presets" section below for more info)
18
- // "postHtmlOptions" arg might be skipped
19
- .process(html, options, preset, postHtmlOptions)
20
- .then(function (result) {
21
- // result.html is minified
22
- })
23
- .catch(function (err) {
24
- console.error(err);
25
- });
26
- ```
27
-
28
-
29
- ## PostHTML
30
- Just add `htmlnano` as a final plugin:
31
- ```js
32
- const posthtml = require('posthtml');
33
- const options = {
34
- removeComments: false, // Disable the module "removeComments"
35
- collapseWhitespace: 'conservative' // Pass options to the module "collapseWhitespace"
36
- };
37
- const posthtmlPlugins = [
38
- /* other PostHTML plugins */
39
-
40
- require('htmlnano')(options)
41
- ];
42
-
43
- const posthtmlOptions = {
44
- // See PostHTML docs
45
- };
46
-
47
- posthtml(posthtmlPlugins)
48
- .process(html, posthtmlOptions)
49
- .then(function (result) {
50
- // result.html is minified
51
- })
52
- .catch(function (err) {
53
- console.error(err);
54
- });
55
- ```
56
-
57
-
58
- ## Webpack
59
-
60
- ```sh
61
- npm install html-minimizer-webpack-plugin --save-dev
62
- npm install htmlnano --save-dev
63
- ```
64
-
65
- ```js
66
- // webpack.config.js
67
- const HtmlMinimizerWebpackPlugin = require('html-minimizer-webpack-plugin');
68
- const htmlnano = require('htmlnano');
69
-
70
- module.exports = {
71
- optimization: {
72
- minimize: true,
73
- minimizer: [
74
- // For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
75
- // `...`,
76
- new HtmlMinimizerWebpackPlugin({
77
- // Add HtmlMinimizerWebpackPlugin's option here, see https://webpack.js.org/plugins/html-minimizer-webpack-plugin/#options
78
- // test: /\.html(\?.*)?$/i,
79
-
80
- // Use htmlnano as HtmlMinimizerWebpackPlugin's minimizer
81
- minify: htmlnano.htmlMinimizerWebpackPluginMinify,
82
- minimizerOptions: {
83
- // Add htmlnano's option here
84
- removeComments: false, // Disable the module "removeComments"
85
- collapseWhitespace: 'conservative' // Pass options to the module "collapseWhitespace"
86
- }
87
- })
88
- ]
89
- }
90
- }
91
- ```
92
-
93
-
94
-
95
- ## Gulp
96
- ```bash
97
- npm i -D gulp-posthtml htmlnano
98
- ```
99
-
100
- ```js
101
- const gulp = require('gulp');
102
- const posthtml = require('gulp-posthtml');
103
- const htmlnano = require('htmlnano');
104
- const options = {
105
- removeComments: false
106
- };
107
-
108
- gulp.task('default', function() {
109
- return gulp
110
- .src('./index.html')
111
- .pipe(posthtml([
112
- // Add `htmlnano` as a final plugin
113
- htmlnano(options)
114
- ]))
115
- .pipe(gulp.dest('./build'));
116
- });
117
- ```
@@ -1,21 +0,0 @@
1
- # Config
2
-
3
- There are two main ways to configure htmlnano:
4
-
5
- ## Passing options to `htmlnano` directly
6
- This is the way described above in the examples.
7
-
8
- ## Using configuration file
9
- Alternatively, you might create a configuration file (e.g., `htmlnanorc.json` or `htmlnanorc.js`) or save options to `package.json` with `htmlnano` key.
10
- `htmlnano` uses `cosmiconfig`, so refer to [its documentation](https://github.com/davidtheclark/cosmiconfig/blob/main/README.md) for a more detailed description.
11
-
12
- If you want to specify a preset that way, use `preset` key:
13
-
14
- ```json
15
- {
16
- "preset": "max",
17
- }
18
- ```
19
-
20
- Configuration files have lower precedence than passing options to `htmlnano` directly.
21
- So if you use both ways, then the configuration file would be ignored.
@@ -1,75 +0,0 @@
1
- # Presets
2
-
3
- A preset is just an object with modules config.
4
-
5
- Currently the following presets are available:
6
- - [safe](https://github.com/posthtml/htmlnano/blob/master/lib/presets/safe.mjs) — a default preset for minifying a regular HTML in a safe way (without breaking anything)
7
- - [ampSafe](https://github.com/posthtml/htmlnano/blob/master/lib/presets/ampSafe.mjs) - same as `safe` preset but for [AMP pages](https://www.ampproject.org/)
8
- - [max](https://github.com/posthtml/htmlnano/blob/master/lib/presets/max.mjs) - maximal minification (might break some pages)
9
-
10
-
11
- You can use them the following way:
12
- ```js
13
- const htmlnano = require('htmlnano');
14
- const ampSafePreset = require('htmlnano').presets.ampSafe;
15
- const options = {
16
- // Your options
17
- };
18
-
19
- htmlnano
20
- .process(html, options, ampSafePreset)
21
- .then(function (result) {
22
- // result.html is minified
23
- })
24
- .catch(function (err) {
25
- console.error(err);
26
- });
27
- ```
28
-
29
- If you skip `preset` argument [`safe`](https://github.com/posthtml/htmlnano/blob/master/lib/presets/safe.mjs) preset would be used by default.
30
-
31
-
32
- If you'd like to define your very own config without any presets pass an empty object as a preset:
33
- ```js
34
- const htmlnano = require('htmlnano');
35
- const options = {
36
- // Your options
37
- };
38
-
39
- htmlnano
40
- .process(html, options, {})
41
- .then(function (result) {
42
- // result.html is minified
43
- })
44
- .catch(function (err) {
45
- console.error(err);
46
- });
47
- ```
48
-
49
-
50
- You might create also your own presets:
51
- ```js
52
- const htmlnano = require('htmlnano');
53
- // Preset for minifying email templates
54
- const emailPreset = {
55
- mergeStyles: true,
56
- minifyCss: {
57
- safe: true
58
- },
59
- };
60
-
61
- const options = {
62
- // Some specific options
63
- };
64
-
65
- htmlnano
66
- .process(html, options, emailPreset)
67
- .then(function (result) {
68
- // result.html is minified
69
- })
70
- .catch(function (err) {
71
- console.error(err);
72
- });
73
- ```
74
-
75
- Feel free [to submit a PR](https://github.com/posthtml/htmlnano/issues/new) with your preset if it might be useful for other developers as well.