Skip to content

Should module scripts always fire load events? #6421

Open
@jakearchibald

Description

@jakearchibald
const script = document.createElement('script');
script.textContent = source;
script.type = 'module';
document.head.append(script);

How would I know when the above script has executed?

  • We know the answer with classic/module scripts with a src, as there's a "load" event.
  • We know the answer with classic scripts without a src, as it's synchronous.

However, module scripts without a src still execute asynchronously, but there's no "load" event.

It feels like we should dispatch a "load" event for all module scripts, not just those from an external file. WDYT @domenic?

This was raised in https://bugs.chromium.org/p/chromium/issues/detail?id=1180532#c8.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions