← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

Import Maps

javascript ES2020 Intermediate

TL;DR

Import maps let browsers resolve bare module specifiers (import 'lodash') without a bundler — mapping module names to URLs in a JSON script tag.

Explanation

Import maps (<script type='importmap'>) define a JSON mapping of bare specifiers to URLs. Without a bundler: import 'lodash' resolves to 'https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm'. This enables CDN-based ES module development without npm/bundler. Also supports scopes for version-specific imports in nested dependencies. Import maps must be declared before any module scripts. Fully supported in Chrome 89+, Firefox 108+, Safari 16.4+. Use esm.sh or skypack for CDN-hosted ES modules.

Common Misconception

Import maps replace bundlers entirely for production — they're best for development or small projects. Production still benefits from bundling for performance.

Why It Matters

Import maps enable framework-free ES module development in browsers, removing the bundler requirement for simple apps and speeding up development iterations.

Common Mistakes

  • Declaring import map after module scripts — must come first.
  • Using CommonJS CDN URLs — import maps need ES module (ESM) URLs.
  • Expecting import maps to work in Node.js — they're a browser feature (Node has its own resolution).

Code Examples

✗ Vulnerable
<!-- Before import maps: requires bundler for bare specifiers -->
<script>
import lodash from 'lodash'; // Fails in browser
</script>
✓ Fixed
<script type="importmap">
{
  "imports": {
    "lodash": "https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm",
    "react": "https://esm.sh/react@18",
    "react-dom/client": "https://esm.sh/react-dom@18/client"
  }
}
</script>
<script type="module">
  import _ from 'lodash'; // Works!
</script>

Added 23 Mar 2026
Views 25
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings W 0 pings T 0 pings F 2 pings S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 1 ping F 0 pings S 1 ping S 0 pings M 0 pings T 0 pings W 0 pings T 1 ping F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 1 ping T 1 ping F 0 pings S 0 pings S 0 pings M 0 pings T 1 ping W 0 pings T
No pings yet today
Amazonbot 8 Perplexity 5 Unknown AI 4 Google 2 SEMrush 2 ChatGPT 1 Majestic 1 Ahrefs 1
crawler 22 pre-tracking 2
DEV INTEL Tools & Severity
🔵 Info ⚙ Fix effort: Low
⚡ Quick Fix
Add <script type='importmap'> before module scripts. Use esm.sh or skypack for CDN ESM URLs. Declare all bare specifiers used in your modules.
📦 Applies To
javascript ES2020 web
🔗 Prerequisites
🔍 Detection Hints
type="importmap"
Auto-detectable: ✗ No
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: Medium Context: File

✓ schema.org compliant