Back to Blog
Tutorial2026-04-05

Import Maps: Manage JavaScript Dependencies Without a Bundler

Learn how to use import maps to manage bare module specifiers in the browser without build tools.

What Are Import Maps?

Import maps are a browser-native feature that lets you control how JavaScript module specifiers are resolved. Instead of relying on a bundler to transform \import lodash from 'lodash'\ into a file path, you tell the browser where to find each package directly.

This is a game-changer for projects that want to skip the build step entirely, or for prototyping and learning environments.

Basic Usage

``html

`

Scoped Imports

You can override resolutions for specific packages — useful when two dependencies need different versions of the same library.

`html `

Modules loaded from \/vendor/legacy-lib/\ will get lodash v3, while everything else gets v4.

Dynamic Import Map Generation

For production use, you can generate import maps dynamically from your package.json or lock file.

`javascript // generate-importmap.js (Node script) import { readFileSync } from 'fs';

const pkg = JSON.parse(readFileSync('package.json', 'utf8')); const importMap = { imports: {} };

for (const [name, version] of Object.entries(pkg.dependencies)) { const cleanVersion = version.replace('^', '').replace('~', ''); importMap.imports[name] = \https://cdn.jsdelivr.net/npm/\${name}@\${cleanVersion}/+esm\; }

console.log(JSON.stringify(importMap, null, 2)); ``

Practical Considerations

Browser support: Import maps are supported in all modern browsers (Chrome 89+, Firefox 108+, Safari 16.4+).

Caching: Use versioned URLs in your import map for proper cache busting. CDN URLs with version numbers work perfectly.

Limitations: Import maps must be declared before any module scripts load. You can only have one import map per page. Dynamic import maps (added after page load) are not yet supported.

Import maps bring the npm-style developer experience to the browser without a build step. They're perfect for documentation sites, learning platforms, internal tools, and any project where build complexity isn't justified.