Skip to content

Built JavaScript is polluting global scope #5232

@ssddanbrown

Description

@ssddanbrown

We're building via esbuild in ESM format (https://esbuild.github.io/api/#format-esm)
For which they state:

Do not forget type="module" as this will break your code in subtle and confusing ways (omitting type="module" means that all top-level variables will end up in the global scope, which will then collide with top-level variables that have the same name in other JavaScript files).

So we need to ensure scripts are fetched as modules.
Browser compatibility looks okay: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#browser_compatibility
Will just need some general testing to ensure nothing messes up, specifically since the script will be deferred.
Need to check with all elements loaded after the script.

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