JavaScript modulesBaseline · Widely available
JavaScript modules allow code to be organized into reusable units. Modules use import to load other modules and export to declare what is available to import from other modules. In HTML, modules are loaded with <script type="module">.
Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since May 9, 2018. Widely available since Nov 9, 2020.
Browser support
DesktopChrome
1–60Not supported
61+Supportedsince Sep 5, 2017
Current: 155Edge
12–15Not supported
16+Supportedsince Oct 17, 2017
Current: 154Firefox
1–59Not supported
60+Supportedsince May 9, 2018
Current: 157Safari
1–10.1Not supported
11+Supportedsince Sep 19, 2017
Current: 27MobileChrome Android
18–60Not supported
61+Supportedsince Sep 5, 2017
Current: 155Firefox Android
4–59Not supported
60+Supportedsince May 9, 2018
Current: 157Safari iOS
1–10.3Not supported
11+Supportedsince Sep 19, 2017
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
Full syntax and examples are on MDN: import.
Feature detection
JS · check before using
// Syntax can't be tested with an if-statement — an unsupported
// browser fails to parse the whole script. Either transpile for older
// targets (e.g. Babel/TypeScript/esbuild), or probe in isolation:
let supported = true;
try {
new Function("/* code that uses the syntax */");
} catch {
supported = false;
}This is a language syntax feature.
Usage share
Sub-features
Support for each part of the feature (15). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| Worklet.ecmascript_modules | 80 | 80 | 114 | 15 | 80 | 114 | 15 |
| script.nomodule | 61 | 16 | 60 | 11 | 61 | 60 | 11 |
| script.type.module | 61 | 16 | 60 | 10.1 | 61 | 60 | 10.3 |
| import | 63 | 79 | 67 | 11.1 | 63 | 67 | 11.3 |
| import_meta | 64 | 79 | 62 | 11.1 | 64 | 62 | 12 |
| import_meta.resolve | 105 | 105 | 106 | 16.4 | 105 | 106 | 16.4 |
| export | 61 | 16 | 60 | 10.1 | 61 | 60 | 10.3 |
| export.arbitrary_module_namespace_identifier_names | 88 | 88 | 87 | 14.1 | 88 | 87 | 14.5 |
| export.default | 61 | 16 | 60 | 10.1 | 61 | 60 | 10.3 |
| export.namespace | 72 | 79 | 80 | 14.1 | 72 | 80 | 14.5 |
| import | 61 | 16 | 60 | 10.1 | 61 | 60 | 10.3 |
| import.arbitrary_module_namespace_identifier_names | 88 | 88 | 87 | 14.1 | 88 | 87 | 14.5 |
| import.import_attributes | 123 | 123 | 138 | 17.2 | 123 | 138 | 17.2 |
| import.worklet_support | ✕ | ✕ | 114 | ✕ | ✕ | 114 | ✕ |
| script.type.module | ✕ | ✕ | 117 | ✕ | ✕ | 117 | ✕ |