htmlnano 2.1.2 → 2.1.4

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 (191) hide show
  1. package/README.md +54 -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 -58
  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 -59
  94. package/dist/helpers.d.ts +16 -0
  95. package/dist/helpers.js +72 -0
  96. package/dist/helpers.mjs +63 -0
  97. package/dist/index.d.ts +79 -0
  98. package/dist/index.js +223 -0
  99. package/dist/index.mjs +209 -0
  100. package/dist/presets/ampSafe.d.ts +47 -0
  101. package/dist/presets/ampSafe.js +19 -0
  102. package/{lib → dist}/presets/ampSafe.mjs +6 -4
  103. package/dist/presets/max.d.ts +47 -0
  104. package/dist/presets/max.js +28 -0
  105. package/{lib → dist}/presets/max.mjs +6 -4
  106. package/dist/presets/safe.d.ts +47 -0
  107. package/dist/presets/safe.js +60 -0
  108. package/{lib → dist}/presets/safe.mjs +13 -20
  109. package/package.json +53 -56
  110. package/.eslintignore +0 -3
  111. package/CHANGELOG.md +0 -409
  112. package/docs/README.md +0 -33
  113. package/docs/babel.config.js +0 -3
  114. package/docs/docs/010-introduction.md +0 -22
  115. package/docs/docs/020-usage.md +0 -117
  116. package/docs/docs/030-config.md +0 -21
  117. package/docs/docs/040-presets.md +0 -75
  118. package/docs/docs/050-modules.md +0 -855
  119. package/docs/docs/060-contribute.md +0 -16
  120. package/docs/docusaurus.config.js +0 -65
  121. package/docs/netlify.toml +0 -4
  122. package/docs/package-lock.json +0 -21630
  123. package/docs/package.json +0 -40
  124. package/docs/sidebars.js +0 -26
  125. package/docs/versioned_docs/version-1.1.1/010-introduction.md +0 -22
  126. package/docs/versioned_docs/version-1.1.1/020-usage.md +0 -77
  127. package/docs/versioned_docs/version-1.1.1/030-config.md +0 -21
  128. package/docs/versioned_docs/version-1.1.1/040-presets.md +0 -75
  129. package/docs/versioned_docs/version-1.1.1/050-modules.md +0 -785
  130. package/docs/versioned_docs/version-1.1.1/060-contribute.md +0 -16
  131. package/docs/versioned_docs/version-2.0.0/010-introduction.md +0 -22
  132. package/docs/versioned_docs/version-2.0.0/020-usage.md +0 -77
  133. package/docs/versioned_docs/version-2.0.0/030-config.md +0 -21
  134. package/docs/versioned_docs/version-2.0.0/040-presets.md +0 -75
  135. package/docs/versioned_docs/version-2.0.0/050-modules.md +0 -838
  136. package/docs/versioned_docs/version-2.0.0/060-contribute.md +0 -16
  137. package/docs/versioned_sidebars/version-1.1.1-sidebars.json +0 -8
  138. package/docs/versioned_sidebars/version-2.0.0-sidebars.json +0 -8
  139. package/docs/versions.json +0 -4
  140. package/index.cjs +0 -11
  141. package/index.d.cts +0 -3
  142. package/index.d.mts +0 -3
  143. package/index.d.ts +0 -94
  144. package/index.mjs +0 -2
  145. package/lib/helpers.cjs +0 -79
  146. package/lib/helpers.mjs +0 -53
  147. package/lib/htmlnano.cjs +0 -202
  148. package/lib/htmlnano.mjs +0 -198
  149. package/lib/modules/collapseAttributeWhitespace.cjs +0 -86
  150. package/lib/modules/collapseAttributeWhitespace.mjs +0 -104
  151. package/lib/modules/collapseBooleanAttributes.cjs +0 -62
  152. package/lib/modules/collapseWhitespace.cjs +0 -100
  153. package/lib/modules/collapseWhitespace.mjs +0 -132
  154. package/lib/modules/custom.cjs +0 -19
  155. package/lib/modules/custom.mjs +0 -16
  156. package/lib/modules/deduplicateAttributeValues.cjs +0 -38
  157. package/lib/modules/deduplicateAttributeValues.mjs +0 -40
  158. package/lib/modules/example.cjs +0 -85
  159. package/lib/modules/example.mjs +0 -75
  160. package/lib/modules/mergeScripts.cjs +0 -54
  161. package/lib/modules/mergeScripts.mjs +0 -56
  162. package/lib/modules/mergeStyles.cjs +0 -38
  163. package/lib/modules/mergeStyles.mjs +0 -36
  164. package/lib/modules/minifyConditionalComments.cjs +0 -47
  165. package/lib/modules/minifyCss.cjs +0 -73
  166. package/lib/modules/minifyCss.mjs +0 -88
  167. package/lib/modules/minifyJs.cjs +0 -103
  168. package/lib/modules/minifyJs.mjs +0 -121
  169. package/lib/modules/minifyJson.cjs +0 -24
  170. package/lib/modules/minifyJson.mjs +0 -21
  171. package/lib/modules/minifySvg.cjs +0 -37
  172. package/lib/modules/minifySvg.mjs +0 -30
  173. package/lib/modules/minifyUrls.cjs +0 -141
  174. package/lib/modules/minifyUrls.mjs +0 -229
  175. package/lib/modules/normalizeAttributeValues.cjs +0 -120
  176. package/lib/modules/normalizeAttributeValues.mjs +0 -140
  177. package/lib/modules/removeAttributeQuotes.cjs +0 -17
  178. package/lib/modules/removeAttributeQuotes.mjs +0 -12
  179. package/lib/modules/removeComments.cjs +0 -86
  180. package/lib/modules/removeEmptyAttributes.cjs +0 -72
  181. package/lib/modules/removeEmptyAttributes.mjs +0 -121
  182. package/lib/modules/removeOptionalTags.cjs +0 -183
  183. package/lib/modules/removeRedundantAttributes.cjs +0 -112
  184. package/lib/modules/removeUnusedCss.cjs +0 -113
  185. package/lib/modules/removeUnusedCss.mjs +0 -122
  186. package/lib/modules/sortAttributes.cjs +0 -98
  187. package/lib/modules/sortAttributesWithLists.cjs +0 -114
  188. package/lib/presets/ampSafe.cjs +0 -18
  189. package/lib/presets/max.cjs +0 -27
  190. package/lib/presets/safe.cjs +0 -65
  191. package/test.js +0 -23
package/CHANGELOG.md DELETED
@@ -1,409 +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.2] - 2025-04-30
6
-
7
- ### Added
8
- - `skipInternalWarnings` flag to avoid `console.warn` output [#293]
9
-
10
- ### Fixed
11
- - Use Node.js `sort` instead of `timsort` [#328]
12
-
13
-
14
- ## [2.1.1] - 2024-04-28
15
-
16
- ### Fixed
17
- - Downlevel-revealed closing comment being deleted in safe mode [#278]
18
-
19
-
20
- ## [2.1.0] - 2023-10-19
21
-
22
- ### Added
23
- - Convert htmlnano to ES Modules [#260]
24
-
25
- ### Fixed
26
- - Collapse white spaces according to specs [#257]
27
-
28
-
29
- ## [2.0.4] - 2023-04-15
30
-
31
- ### Fixed
32
- - Should not minify `<script>` and `<style>` with SRI [#220]
33
- - Should not merge `<style>` or `<script>` with SRI [#220]
34
- - Should not minify json with SRI [#220]
35
-
36
-
37
- ## [2.0.3] - 2022-11-13
38
-
39
- ### Added
40
- - Minify function for `HtmlMinimizerWebpackPlugin`
41
-
42
- ### Fixed
43
- - `collapseWhitespace`: handle textNode when comment is preserved [#184]
44
- - `minifyUrls`: srcset & javascript: url [#185]
45
- - Correct missing value default usage
46
- - `collapseBooleanAttributes`: empty string attributes
47
- - Guard type of attributes' value [#195]
48
- - Do not choke on svg error [#197]
49
-
50
- ### Changed
51
- - Minify based on invalid value default
52
- - Avoid hardcoding preset keys
53
-
54
-
55
- ## [2.0.2] - 2022-04-06
56
-
57
- ### Fixed
58
- - JSON-LD crash [#182]
59
-
60
-
61
- ## [2.0.1] - 2022-04-04
62
- **This version contains a critical bug [#182].**
63
- **Don't use it.**
64
-
65
- ### Changed
66
- - Speed improvements [#127]
67
- - Fix `<img sizes>` [#180]
68
-
69
-
70
- ## [2.0.0] - 2022-01-12
71
- *The major version has to be released because of vulnerability in PostCSS (see [#165])*
72
-
73
- ### Changed
74
- - 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
75
- - Disable `mergeScripts` & `mergeStyles` in the safe preset [#170].
76
-
77
-
78
- ## [1.1.1] - 2021-09-19
79
- This version fixes fatal errors introduced in [1.1.0].
80
-
81
-
82
- ## [1.1.0] - 2021-09-19
83
- *This version contains fatal errors. Please use [1.1.1] instead.*
84
-
85
- ### Added
86
- - Collapse missing value default attribute in `removeRedundantAttributes` [#158].
87
- - New `normalizeAttributeValues` module to normalize casing of attribute values [#163].
88
- - Custom matcher for `removeComments` [#156].
89
-
90
- ### Changed
91
- - Remove more empty attributes in `removeEmptyAttributes` [#161].
92
- - Enhance collapse whitespace in `collapseWhitespace` [#145].
93
- - `minifyJs` and `minifyUrls` enhancement [#159].
94
- - Enhance attribute collapse whitespace in `collapseAttributeWhitespace` [#157].
95
-
96
-
97
-
98
- ## [1.0.1] - 2021-09-11
99
- ### Added
100
- - Support of [@novaatwarren/uncss](https://github.com/novaatwarren/uncss) fork [#154]
101
-
102
- ### Changed
103
- - SVGO plugins configuration [#153]
104
-
105
-
106
-
107
- ## [1.0.0] - 2021-04-17
108
- 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 🎉
109
-
110
- It doesn't contain anything new from the previous [0.2.9](https://github.com/posthtml/htmlnano/releases/tag/0.2.9) release.
111
- We just did a major upgrade of two dependencies: [PurgeCSS](https://purgecss.com/) and [SVGO](https://github.com/svg/svgo),
112
- which changed their config format.
113
- Thus we have to do a major release of `htmlnano`.
114
-
115
- 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.
116
- 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.
117
-
118
-
119
-
120
- ## [0.2.9] - 2021-04-11
121
- ### Added
122
- - `minifyConditionalComment` support `<html>` [#125].
123
- - Minify JS within `<script type="module">` [#135].
124
-
125
- ### Fixed
126
- - `collapseWhitespaces` around comment [#120].
127
- - handle `CDATA` inside script correctly [#122].
128
- - Minify SVG correctly [#129].
129
-
130
- ### Changed
131
- - Upgrade to terser@5 (JS minification).
132
-
133
-
134
-
135
- ## [0.2.8] - 2020-11-15
136
- ### Added
137
- - [`removeOptionalTags`](https://github.com/posthtml/htmlnano#removeoptionaltags) [#110].
138
- - [`sortAttributes`](https://github.com/posthtml/htmlnano#removeoptionaltags) [#113].
139
- - `source[src]` and `srcset` support to `minifyUrls` [#117].
140
- - [`minifyConditionalComments`](https://github.com/posthtml/htmlnano#minifyconditionalcomments) [#119].
141
-
142
- ### Changed
143
- - Sort by frequency `sortAttributesWithLists` [#111].
144
- - Strip more spaces in `collapseWhitespace` [#112].
145
- - Remove `loading="eager"` from `<img>` and `<iframe>` [#114].
146
- - Remove redundant `type` from `<script>` [#114].
147
- - Strip whitespaces between textnode and element [#116].
148
-
149
-
150
-
151
- ## [0.2.7] - 2020-10-17
152
- ### Added
153
- - More aggressive whitespace removal option [#90].
154
- - Cloudflare SSE support to `removeComments` [#94].
155
- - Improve compression ratio by sorting attribute values [#95].
156
- - New `minifyUrls` module [#98].
157
- - New `removeAttributeQuotes` module [#104].
158
- - Remove `type=text/css` for `link[rel=stylesheet]` [#102].
159
- - Collapse `crossorigin` attributes [#107].
160
- - Exclude excerpt comment for common CMS [#108].
161
-
162
- ### Fixed
163
- - Keep JS inside SVG wrapped in `//<![CDATA[ //]]` [#88].
164
-
165
-
166
- ## [0.2.6] - 2020-07-15
167
- ### Added
168
- - Let PostHTML options to be passed.
169
-
170
- ### Fixed
171
- - `<script>` tags merging without content.
172
-
173
-
174
- ## [0.2.5] - 2019-11-09
175
- ### Added
176
- - Option to remove unused CSS using PurgeCSS [#84].
177
-
178
- ### Fixed
179
- - Keep the order of inline and external JS [#80].
180
-
181
-
182
- ## [0.2.4] - 2019-07-11
183
- ### Fixed
184
- - Remove crossorigin from boolean attribute [#78], [#79].
185
- - Disable SVGO plugin convertShapeToPath in safe preset [#76].
186
-
187
-
188
- ## [0.2.3] - 2019-02-14
189
- ### Fixed
190
- - Keep `<g>` in SVG by default [#71].
191
-
192
-
193
- ## [0.2.2] - 2019-01-03
194
- ### Added
195
- - `removeUnusedCss` module [#36].
196
-
197
- ### Fixed
198
- - Bug when `tag === false` [#66].
199
- - Add `crossorigin` to boolean attributes [#67].
200
-
201
-
202
- ## [0.2.1] - 2018-12-01
203
- ### Fixed
204
- - Disable JS minifying on AMP pages [#65].
205
-
206
- ## [0.2.0] - 2018-09-14
207
- ### Breaking changes
208
- - 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:
209
- * [htmlnano docs](https://github.com/posthtml/htmlnano#minifycss)
210
- * [cssnano docs](https://cssnano.co/guides/presets)
211
- * Diff of commit [979f2c](https://github.com/posthtml/htmlnano/commit/979f2c821892c9e979e8b85f74ed0394330fceaf) with the changes of related docs.
212
-
213
- ### Added
214
- - Add presets [#64].
215
- - Add `collapseAttributeWhitespace` module for collapsing spaces in list-like attributes [#25].
216
- - Add `deduplicateAttributeValues` module for de-duplicating values in list-like attributes [#39].
217
- - Better support for AMP pages [#59].
218
- - Collapse whitespaces between top-level tags [#24].
219
-
220
- ### Changed
221
- - Improve whitespace normalization using `normalize-html-whitespace` [#21].
222
-
223
- ### Fixed
224
- - Don't collapse `visible="false"` attributes in A-Frame pages [#62].
225
-
226
-
227
-
228
- ## [0.1.10] - 2018-08-03
229
- ### Fixed
230
- - Merging `<script>` tags without leading `;` [#55].
231
-
232
-
233
- ## [0.1.9] - 2018-04-29
234
- ### Fixed
235
- - Default minification options safety [#50].
236
-
237
-
238
- ## [0.1.8] - 2018-04-17
239
- ### Fixed
240
- - ES6+ minification [#48].
241
-
242
-
243
-
244
- ## [0.1.7] - 2018-03-13
245
- ### Fixed
246
- - Update dependencies which also fixes the SVG minification bug [#47].
247
-
248
-
249
-
250
- ## [0.1.6] - 2017-06-27
251
- ### Fixed
252
- - "Not a function" error [#42].
253
-
254
-
255
-
256
- ## [0.1.5] - 2016-04-24
257
- ### Added
258
- - Minify SVG [#28].
259
- - Merge `<script>` [#19].
260
-
261
- ### Changed
262
- - Remove redundant `type="submit"` from `<button>` [#31].
263
-
264
- ### Fixed
265
- - Windows build [#30].
266
-
267
-
268
- ## [0.1.4] - 2016-02-16
269
- ### Added
270
- - Minify JSON.
271
- - Merge multiple `<style>` into one.
272
- - Collapse boolean attributes.
273
- - Remove redundant attributes.
274
- - HTML minifiers benchmark [#22].
275
-
276
- ### Changed
277
- - Expand list of JSON-like mime types [#20].
278
-
279
-
280
- ## [0.1.3] - 2016-02-09
281
- ### Fixed
282
- - Don't alter HTML comments inside not relevant modules [#17].
283
-
284
-
285
- ## [0.1.2] - 2016-02-07
286
- ### Fixed
287
- - Don't remove conditional comments in safe mode [#13].
288
- - Downgrade: `String.startsWith -> String.search`.
289
-
290
-
291
- ## [0.1.1] - 2016-01-31
292
- ### Added
293
- - Minify CSS inside `<style>` tags and `style` attributes.
294
- - Minify JS inside `<script>` tags and `on*` attributes.
295
-
296
- ### Changed
297
- - Remove attributes that contains only white spaces.
298
-
299
-
300
- [2.1.2]: https://github.com/posthtml/htmlnano/compare/2.1.1...2.1.2
301
- [2.1.1]: https://github.com/posthtml/htmlnano/compare/2.1.0...2.1.1
302
- [2.1.0]: https://github.com/posthtml/htmlnano/compare/2.0.4...2.1.0
303
- [2.0.4]: https://github.com/posthtml/htmlnano/compare/2.0.3...2.0.4
304
- [2.0.3]: https://github.com/posthtml/htmlnano/compare/2.0.2...2.0.3
305
- [2.0.2]: https://github.com/posthtml/htmlnano/compare/2.0.1...2.0.2
306
- [2.0.1]: https://github.com/posthtml/htmlnano/compare/2.0.0...2.0.1
307
- [2.0.0]: https://github.com/posthtml/htmlnano/compare/1.1.1...2.0.0
308
- [1.1.1]: https://github.com/posthtml/htmlnano/compare/1.1.0...1.1.1
309
- [1.1.0]: https://github.com/posthtml/htmlnano/compare/1.0.1...1.1.0
310
- [1.0.1]: https://github.com/posthtml/htmlnano/compare/1.0.0...1.0.1
311
- [1.0.0]: https://github.com/posthtml/htmlnano/compare/0.2.9...1.0.0
312
- [0.2.9]: https://github.com/posthtml/htmlnano/compare/0.2.8...0.2.9
313
- [0.2.8]: https://github.com/posthtml/htmlnano/compare/0.2.7...0.2.8
314
- [0.2.7]: https://github.com/posthtml/htmlnano/compare/0.2.6...0.2.7
315
- [0.2.6]: https://github.com/posthtml/htmlnano/compare/0.2.5...0.2.6
316
- [0.2.5]: https://github.com/posthtml/htmlnano/compare/0.2.4...0.2.5
317
- [0.2.4]: https://github.com/posthtml/htmlnano/compare/0.2.3...0.2.4
318
- [0.2.3]: https://github.com/posthtml/htmlnano/compare/0.2.2...0.2.3
319
- [0.2.2]: https://github.com/posthtml/htmlnano/compare/0.2.1...0.2.2
320
- [0.2.1]: https://github.com/posthtml/htmlnano/compare/0.2.0...0.2.1
321
- [0.2.0]: https://github.com/posthtml/htmlnano/compare/0.1.10...0.2.0
322
- [0.1.10]: https://github.com/posthtml/htmlnano/compare/0.1.9...0.1.10
323
- [0.1.9]: https://github.com/posthtml/htmlnano/compare/0.1.8...0.1.9
324
- [0.1.8]: https://github.com/posthtml/htmlnano/compare/0.1.7...0.1.8
325
- [0.1.7]: https://github.com/posthtml/htmlnano/compare/0.1.6...0.1.7
326
- [0.1.6]: https://github.com/posthtml/htmlnano/compare/0.1.5...0.1.6
327
- [0.1.5]: https://github.com/posthtml/htmlnano/compare/0.1.4...0.1.5
328
- [0.1.4]: https://github.com/posthtml/htmlnano/compare/0.1.3...0.1.4
329
- [0.1.3]: https://github.com/posthtml/htmlnano/compare/0.1.2...0.1.3
330
- [0.1.2]: https://github.com/posthtml/htmlnano/compare/0.1.1...0.1.2
331
- [0.1.1]: https://github.com/posthtml/htmlnano/compare/0.1.0...0.1.1
332
-
333
- [#328]: https://github.com/posthtml/htmlnano/issues/328
334
- [#293]: https://github.com/posthtml/htmlnano/issues/293
335
- [#278]: https://github.com/posthtml/htmlnano/issues/278
336
- [#260]: https://github.com/posthtml/htmlnano/issues/260
337
- [#257]: https://github.com/posthtml/htmlnano/issues/257
338
- [#220]: https://github.com/posthtml/htmlnano/issues/220
339
- [#197]: https://github.com/posthtml/htmlnano/issues/197
340
- [#195]: https://github.com/posthtml/htmlnano/issues/195
341
- [#185]: https://github.com/posthtml/htmlnano/issues/185
342
- [#184]: https://github.com/posthtml/htmlnano/issues/184
343
- [#182]: https://github.com/posthtml/htmlnano/issues/182
344
- [#180]: https://github.com/posthtml/htmlnano/issues/180
345
- [#170]: https://github.com/posthtml/htmlnano/issues/170
346
- [#168]: https://github.com/posthtml/htmlnano/issues/168
347
- [#165]: https://github.com/posthtml/htmlnano/issues/165
348
- [#163]: https://github.com/posthtml/htmlnano/issues/163
349
- [#161]: https://github.com/posthtml/htmlnano/issues/161
350
- [#159]: https://github.com/posthtml/htmlnano/issues/159
351
- [#158]: https://github.com/posthtml/htmlnano/issues/158
352
- [#157]: https://github.com/posthtml/htmlnano/issues/157
353
- [#156]: https://github.com/posthtml/htmlnano/issues/156
354
- [#154]: https://github.com/posthtml/htmlnano/issues/154
355
- [#153]: https://github.com/posthtml/htmlnano/issues/153
356
- [#145]: https://github.com/posthtml/htmlnano/issues/145
357
- [#135]: https://github.com/posthtml/htmlnano/issues/135
358
- [#129]: https://github.com/posthtml/htmlnano/issues/129
359
- [#127]: https://github.com/posthtml/htmlnano/issues/127
360
- [#125]: https://github.com/posthtml/htmlnano/issues/125
361
- [#122]: https://github.com/posthtml/htmlnano/issues/122
362
- [#120]: https://github.com/posthtml/htmlnano/issues/120
363
- [#119]: https://github.com/posthtml/htmlnano/issues/119
364
- [#117]: https://github.com/posthtml/htmlnano/issues/117
365
- [#116]: https://github.com/posthtml/htmlnano/issues/116
366
- [#114]: https://github.com/posthtml/htmlnano/issues/114
367
- [#113]: https://github.com/posthtml/htmlnano/issues/113
368
- [#112]: https://github.com/posthtml/htmlnano/issues/112
369
- [#111]: https://github.com/posthtml/htmlnano/issues/111
370
- [#110]: https://github.com/posthtml/htmlnano/issues/110
371
- [#108]: https://github.com/posthtml/htmlnano/issues/108
372
- [#107]: https://github.com/posthtml/htmlnano/issues/107
373
- [#104]: https://github.com/posthtml/htmlnano/issues/104
374
- [#102]: https://github.com/posthtml/htmlnano/issues/102
375
- [#98]: https://github.com/posthtml/htmlnano/issues/98
376
- [#95]: https://github.com/posthtml/htmlnano/issues/95
377
- [#94]: https://github.com/posthtml/htmlnano/issues/94
378
- [#90]: https://github.com/posthtml/htmlnano/issues/90
379
- [#88]: https://github.com/posthtml/htmlnano/issues/88
380
- [#84]: https://github.com/posthtml/htmlnano/issues/84
381
- [#80]: https://github.com/posthtml/htmlnano/issues/80
382
- [#79]: https://github.com/posthtml/htmlnano/issues/79
383
- [#78]: https://github.com/posthtml/htmlnano/issues/78
384
- [#76]: https://github.com/posthtml/htmlnano/issues/76
385
- [#71]: https://github.com/posthtml/htmlnano/issues/71
386
- [#67]: https://github.com/posthtml/htmlnano/issues/67
387
- [#66]: https://github.com/posthtml/htmlnano/issues/66
388
- [#65]: https://github.com/posthtml/htmlnano/issues/65
389
- [#64]: https://github.com/posthtml/htmlnano/issues/64
390
- [#62]: https://github.com/posthtml/htmlnano/issues/62
391
- [#59]: https://github.com/posthtml/htmlnano/issues/59
392
- [#55]: https://github.com/posthtml/htmlnano/issues/55
393
- [#50]: https://github.com/posthtml/htmlnano/issues/50
394
- [#48]: https://github.com/posthtml/htmlnano/issues/48
395
- [#47]: https://github.com/posthtml/htmlnano/issues/47
396
- [#42]: https://github.com/posthtml/htmlnano/issues/42
397
- [#39]: https://github.com/posthtml/htmlnano/issues/39
398
- [#36]: https://github.com/posthtml/htmlnano/issues/36
399
- [#31]: https://github.com/posthtml/htmlnano/issues/31
400
- [#30]: https://github.com/posthtml/htmlnano/issues/30
401
- [#28]: https://github.com/posthtml/htmlnano/issues/28
402
- [#25]: https://github.com/posthtml/htmlnano/issues/25
403
- [#24]: https://github.com/posthtml/htmlnano/issues/24
404
- [#22]: https://github.com/posthtml/htmlnano/issues/22
405
- [#21]: https://github.com/posthtml/htmlnano/issues/21
406
- [#20]: https://github.com/posthtml/htmlnano/issues/20
407
- [#19]: https://github.com/posthtml/htmlnano/issues/19
408
- [#17]: https://github.com/posthtml/htmlnano/issues/17
409
- [#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.