Widely availableSuitable for production when it improves semantics, input, or browser integration.

Overview

A <script type="importmap"> HTML element provides an import map as a JSON string. An import map controls how the browser should resolve module specifiers when importing JavaScript modules. It is most useful when native HTML semantics or browser capabilities can replace custom implementation work.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
89
89
108
16.4
89
16.4
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

HTML
<script type="importmap">
{
  "imports": {
    "react": "https://esm.sh/react@18",
    "react-dom": "https://esm.sh/react-dom@18"
  }
}
</script>
<script type="module">
import React from 'react';
</script>

Live demo

Specifier mapping idea

Show how import maps replace bare specifiers with concrete module URLs.

PreviewFullscreen

Import map anatomy

Break an import map into specifiers, URLs, and scope overrides.

PreviewFullscreen

Authoring checklist

Use one map early in the document and keep the mapping explicit.

PreviewFullscreen

Use cases

  • Control document behavior

    Use Import maps to influence loading, metadata, or script behavior at the document level.

  • Tune performance strategy

    Apply Import maps when earlier resource hints or document settings improve startup or runtime behavior.

Cautions

  • Test Import maps in your target browsers and input environments before depending on it as a primary behavior.

Accessibility

  • Make sure Import maps supports the intended task without making the page harder to perceive, understand, or operate.

Powered by web-features