html-minifier-terser: minifier removes script-type-module attribute. it should not.
hi, test case:
input (test.html):
<script type="module">console.log('hello')</script>
command:
./node_modules/.bin/html-minifier-terser --remove-script-type-attributes test.html
output:
<script>console.log('hello')</script>
as you see, the type="module" part got removed. it should not be removed, because when a script tag has type-module, it’s content will be executed differently. also, the documentation for the flag says:
"
–remove-script-type-attributes Remove type=“text/javascript” from script tags. Other type attribute values are left intact.
"
which is not correct with the behavior.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 21 (15 by maintainers)
Commits related to this issue
- Keep module type - closes #31 — committed to terser/html-minifier-terser by deleted user 4 years ago
- Keep module type definition - closes #31 — committed to terser/html-minifier-terser by deleted user 4 years ago
- Keep module type definition - closes #31 For ECMAScript modules in browsers the type definition is required to treat them as such. Until now every script type was removed as browsers can still evalu... — committed to terser/html-minifier-terser by deleted user 4 years ago
- Keep module type definition - closes #31 For ECMAScript modules in browsers the type definition is required to treat them as such. Until now every script type was removed as browsers can still evalu... — committed to terser/html-minifier-terser by deleted user 4 years ago
- Keep module type definition - closes #31 For ECMAScript modules in browsers the type definition is required to treat them as such. Until now every script type was removed as browsers can still evalu... — committed to terser/html-minifier-terser by deleted user 4 years ago
So far this is still the case. We have to extend the checks in the minifier and introduce a new array which is not removed but includes the supported types.
PRs which implement this are very welcome. You can also use ignore comment, see https://github.com/DanielRuf/html-minifier-terser#ignoring-chunks-of-markup
At the moment the docs are incomplete regarding this.
@evilebottnawi https://github.com/DanielRuf/html-minifier-terser/issues/31#issuecomment-588996133 😉