Web APIs
Browser import map
HTML mechanism for mapping module specifiers to URLs in browser module resolution. The map does not install or bundle dependencies. Its registrations must be available for relevant module requests. Multi-file example: save each listed file separately, then serve the entry over local HTTP in a browser. See the packaged fixture for the original files.
Formal Syntax & Structure
javascript syntaxjavascript
<script type="importmap">{"imports":{"name":"./module.js"}}</script>Working Example
Example Snippetjavascript
// File: index.html<!doctype html><html lang="en"><meta charset="utf-8"><title>Import map demo</title><script type="importmap">{"imports":{"pricing":"./pricing.js"}}</script><script type="module" src="./main.js"></script></html>
// File: pricing.jsexport const unit = 6;
// File: main.jsimport { unit } from "pricing";console.log(unit * 3);