# \[rel="modulepreload"\]

> The `modulepreload` value of the `rel` HTML attribute preloads a JS module and its dependencies.

## What is modulepreload and how is it different from preload?

The value of the `rel` attribute of the `<link>` element that downloads, parses and compiles a JS module ahead of time. It reduces the delay caused by the chain of module imports when the module is actually requested.

- Topic: Links
- Type: attribute
- Browser support: Chrome 66+, Chrome Android 66+, Edge 79+, Firefox 115+, Firefox Android 115+, Safari 17+, Safari iOS 17+

## Example

Wrong:

```html
<link rel="preload" href="/app.js" as="script">
<script type="module" src="/app.js"></script>
```

Right:

```html
<link rel="modulepreload" href="/app.js">
<script type="module" src="/app.js"></script>
```

`modulepreload` fetches the file in module mode, so the module script reuses it instead of downloading it again.

## Common mistakes

- Preloading a module with `rel='preload'`, so it is fetched twice.

## Key points

- ES modules are preloaded with `rel='modulepreload'`, not `rel='preload' as='script'`.
- The `href` matches the exact URL the module is imported from.
- Only modules needed for the first render are preloaded.

## Interview questions

### Does modulepreload load the module's imports too?

Browsers may fetch the dependencies, but it is not guaranteed, so list important dependencies as their own `modulepreload` links.

### Does modulepreload run the module?

No, it fetches and parses the module ahead of time. The code runs only when the module is imported.

## Related cards

- [\[rel="preload"\]](https://wonderium.dev/html/rel-preload.md)
- [`<script type="importmap">`](https://wonderium.dev/html/import-map.md)
- [`<script>`](https://wonderium.dev/html/script.md)
- [import / export](https://wonderium.dev/js/import-export.md)

---

- Level: [HTML](https://wonderium.dev/html.md)
- HTML version: https://wonderium.dev/html/rel-modulepreload
- Last updated: 2026-11-25
