# preload()

> The `preload()` API in React DOM eagerly fetches a resource such as a stylesheet, font or script.

## How do I preload fonts, images and stylesheets in React?

The API that tells the browser to start downloading a resource, such as a stylesheet, font or image, as early as possible. Called during rendering or in event handlers to avoid waterfalls.

- Topic: APIs [React DOM]
- Type: API

## Example

Wrong:

```jsx
function App() {
  preload('/fonts/inter.woff2', { as: 'font' });
  return <Page />;
}
```

Right:

```jsx
function App() {
  preload('/fonts/inter.woff2', { as: 'font', crossOrigin: 'anonymous' });
  return <Page />;
}
```

Fonts are always fetched in CORS mode, so the preload needs `crossOrigin` to match and avoid a second download.

## Common mistakes

- Preloading a font without `crossOrigin` and seeing it fetched twice.
- Preloading many images, which delays the resources that matter for LCP.

## Key points

- `preload` is imported from 'react-dom' and always gets the `as` option, such as 'font', 'image' or 'style'.
- Font preloads pass `crossOrigin`, otherwise the font is downloaded twice.
- Only resources needed for the first view are preloaded, not everything on the page.

## Interview questions

### preload() vs a link rel preload tag: what is the difference?

Both start a download early. `preload()` can be called from any component, and React removes duplicates and places the tag in the document head.

### Does preload work during server rendering?

Yes. During server rendering React adds the preload to the HTML head; on the client it inserts the tag when the code runs.

## Related cards

- [\[rel="preload"\]](https://wonderium.dev/html/rel-preload.md)
- [preinit()](https://wonderium.dev/react/preinit.md)
- [preconnect()](https://wonderium.dev/react/preconnect.md)
- [@font-face](https://wonderium.dev/css/font-face.md)
- [LCP](https://wonderium.dev/web/lcp.md)

---

- Level: [React](https://wonderium.dev/react.md)
- HTML version: https://wonderium.dev/react/preload
- Last updated: 2026-11-25
