question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Customize type attribute of script

See original GitHub issue

Is your feature request related to a problem? Please describe.

As of 5.41.0, webpack will output .mjs by default when experimental ECMAScript modules support is enabled. You can see a demo here.

I’m wondering if html-webpack-plugin can support customizing the type attribute of script element:

<script type='module' src=''></script>

Describe the solution you’d like

Add type='module' to script automatically when users enable experimental ESM support in webpack.config.js.

module.exports = {
  experiments: {
    outputModule: true,
  },
};

Describe alternatives you’ve considered

Add a type option so users can customize as they wish.

Additional context

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
chenxsancommented, Aug 3, 2021

Modules are deferred automatically, so there’s no need to set one.

0reactions
hronrocommented, Apr 16, 2022

not stale

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML script type Attribute - W3Schools
Definition and Usage. The type attribute specifies the type of the script. The type attribute identifies the content between the <script> and </script>...
Read more >
Custom type attribute on <script> tag - valid html?
On the site I work on, we're using <script> tags with a src attribute but with a custom type (let's call it type="text/x-custom"...
Read more >
The Script element - HTML: HyperText Markup Language
This attribute specifies the URI of an external script; this can be used as an alternative to embedding a script directly within a...
Read more >
HTML | <script> type Attribute - GeeksforGeeks
HTML | <script> type Attribute · Syntax: · Attribute Values: It contains a single value i.e media_type which specifies the MIME type of...
Read more >
Scripts in HTML documents - W3C
Local declaration of a scripting language ... The type attribute must be specified for each SCRIPT element instance in a document. The value...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found