html-webpack-plugin icon indicating copy to clipboard operation
html-webpack-plugin copied to clipboard

Boolean attributes can be made shorter

Open koooge opened this issue 3 years ago • 3 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

  └── [email protected]

koooge avatar Nov 19 '21 23:11 koooge

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

jantimon avatar Nov 21 '21 08:11 jantimon

It does not. I opened #1705 .

koooge avatar Nov 21 '21 13:11 koooge

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

We tried to pick only the safe values: https://github.com/jantimon/html-webpack-plugin/pull/1048

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

jantimon avatar Nov 21 '21 14:11 jantimon

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

alexander-akait avatar Jun 09 '23 20:06 alexander-akait