Skip to content

How to handle non-type=”module” scripts in HTML Modules? #798

Open
@travisleithead

Description

@travisleithead

(Original OP by @dandclark)

The HTML Modules design discussed thus far forbids modules from containing non-module scripts. This allows for overall easier integration into ES modules (which would otherwise be difficult if parsing an HTML module could run script prior to module graph instantiation/evaluation), and prevents issues with parser-blocking scripts like those in HTML Imports.

However it’s not clear how this should best be achieved. Our original proposal suggested that non-module scripts in an HTML Module should be automatically converted to type=”module”. This is simple and saves the developer some typing, and is in a similar spirit as the JavaScript module behavior of silently enabling strict mode for all module scripts. The disadvantage is that it could be potentially confusing for a developer new to the feature. I first saw this concern raised here and here, and more recently on this blink-dev thread.

The alternative would be to treat a non-module script in an HTML Module as a parse error, resulting in a failure to instantiate the module. This is much more unambiguous, but devlopers might get a bit tired of needing to inlcude `type=”module” for every script element.

Since there has been discussion on this across a few different threads, I wanted to give a home to the topic here and see if some consensus can be reached.

Thoughts?

See also (#793)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions