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

Most upvoted comments

We may have to refactor that.

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.