# \[rel="preconnect"\]

> The `preconnect` value of the `rel` HTML attribute tells the browser to open a connection to an origin in advance.

## What does rel preconnect do and when should I use it?

The value of the `rel` attribute of the `<link>` element that establishes an early connection to another origin, including DNS lookup, TCP handshake and TLS negotiation. Useful for critical third-party origins such as CDNs or font services.

- Topic: Links
- Type: attribute
- Browser support: Chrome 46+, Chrome Android 46+, Edge 79+, Firefox 39+, Firefox Android 39+, Safari 11.1+, Safari iOS 11.3+

## Example

Wrong:

```html
<link rel="preconnect" href="https://fonts.example.com">
<link rel="stylesheet" href="https://fonts.example.com/inter.css">
```

Right:

```html
<link rel="preconnect" href="https://fonts.example.com" crossorigin>
<link rel="stylesheet" href="https://fonts.example.com/inter.css">
```

Font files are fetched in CORS mode, so the preconnect needs `crossorigin` to match and be reused.

## Common mistakes

- Preconnecting to a font host without `crossorigin`, so the connection is not reused.

## Key points

- Font origins are preconnected with the `crossorigin` attribute.
- Only a few critical origins are preconnected, not every third-party domain.
- The origin is one the page will request soon, otherwise the connection is wasted.

## Interview questions

### How many origins should I preconnect to?

Only a few critical ones. Each open connection costs resources and is closed if it is not used soon.

### What is the difference between preconnect and dns-prefetch?

`dns-prefetch` only resolves the domain name, while `preconnect` also opens the connection, including the TLS handshake.

## Related cards

- [\[rel="dns-prefetch"\]](https://wonderium.dev/html/rel-dns-prefetch.md)
- [\[rel="preload"\]](https://wonderium.dev/html/rel-preload.md)
- [preconnect()](https://wonderium.dev/react/preconnect.md)
- [TLS](https://wonderium.dev/web/tls.md)
- [`<link>`](https://wonderium.dev/html/link.md)

---

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