terser / html-minifier-terser

actively maintained fork of html-minifier - minify HTML, CSS and JS code using terser - supports ES6 code
https://terser.org/html-minifier-terser
MIT License
376 stars 30 forks source link

Issue regarding whitespace minification #122

Closed connorjclark closed 2 years ago

connorjclark commented 2 years ago

Cross-posting from an issue on emscripten, which uses this tool

https://github.com/emscripten-core/emscripten/issues/16656

image

DanielRuf commented 2 years ago

Hi @connorjclark,

thanks for reporting this.

Please check the settings at https://terser.org/html-minifier-terser/ and play a bit with these.

Can you please share a reproducible testcase with html code that we can copy and paste? The image is not that helpful for us. Thank you very much.

connorjclark commented 2 years ago
<p>
  To report issues, contact Connor (discord connorclark#9300) or file an issue on the <a target="_blank"
    href="https://github.com/ArmageddonGames/ZeldaClassic">GitHub</a> issue tracker.
</p>
npx html-minifier-terser web/tmp.html --collapse-whitespace --collapse-inline-tag-whitespace

(both flags needed)

result

<p>To report issues, contact Connor (discord connorclark#9300) or file an issue on the<a target="_blank" href="https://github.com/ArmageddonGames/ZeldaClassic">GitHub</a>issue tracker.</p>
DanielRuf commented 2 years ago

The maintainers of emscripten should probably remove the inline option. There are good reasons why "Collapse inline tag whitespace" is in red. Because it can break stuff.

In html-minifier all options / flags are disabled by default as you can see in the readme. Please tell the emscripten maintainers that the collapseInlineTagWhitespace should be removed.

Nothing to fix on our end since it works like expected.

See also: https://github.com/kangax/html-minifier/issues/1082 https://github.com/kangax/html-minifier/issues/691 https://github.com/kangax/html-minifier/issues/706#issuecomment-242338368