jantimon/html-webpack-plugin

Boolean attributes can be made shorter

koooge opened this issue ยท 4 comments

Hi there,

Current behaviour ๐Ÿ’ฃ

http-webpack-plugin generates:

<script defer="defer">
<script defer="defer" nomodule="">

Expected behaviour โ˜€๏ธ

defer is boolean attributes https://html.spec.whatwg.org/multipage/scripting.html#attr-script-defer .

<script defer>
<script defer nomodule>

I am not sure if it's on purpose. They are equivalent but it would be shorter and simpler.

Reproduction Example ๐Ÿ‘พ

Environment ๐Ÿ–ฅ

$ npm ls html-webpack-plugin

  โ””โ”€โ”€ html-webpack-plugin@5.5.0

Doesn't the html-minifier minify that for production?

It does not. I opened #1705 .

I guess changing this default setting might break some production apps..

We tried to pick only the safe values:
#1048

but you can easily adjust the minification settings according to your requirements in the options

Yes, we can't enable it by default because of this http://perfectionkills.com/experimenting-with-html-minifier/#collapse_boolean_attributes, it can be unsafe, so please enable it on own side if it is safe for you, anyway thank you for the issue