Preconnect is a resource hint, written as <link rel="preconnect" href="https://origin.example">, that tells the browser to set up a connection to another origin in advance, completing the DNS lookup, the TCP handshake and the TLS negotiation before the page actually requests anything from that origin. When the request arrives, it can be sent immediately over a warm connection.
Web performance practice treats preconnect as a low-cost way to remove connection latency from the critical path, especially for third-party fonts, image CDNs, API hosts and analytics endpoints. Used selectively, it can improve LCP and FCP by tens to hundreds of milliseconds; used indiscriminately, it wastes sockets and processor time on connections that are never used.
How preconnect removes connection setup time
Preconnect removes connection setup time by performing the network handshakes in parallel with other work, instead of waiting until the browser discovers a resource on that origin. Without the hint, the browser learns about a cross-origin font, for example, only after it has downloaded and parsed the stylesheet that references it.
Each new HTTPS connection requires several round trips. On a mobile network with a round-trip time of 100 to 300 ms, the combined cost easily reaches 300 to 900 ms before a single byte of the resource is transferred. Preconnect moves that cost earlier, so it overlaps with HTML parsing and other downloads.
The table breaks down the steps that preconnect performs and their typical cost.
| Step | Round trips | What happens |
|---|---|---|
| DNS resolution | Usually 1, often cached | Hostname is translated to an IP address |
| TCP handshake | 1 | SYN, SYN-ACK and ACK establish the socket |
| TLS 1.3 handshake | 1 | Keys are agreed and the certificate is verified |
| TLS 1.2 handshake | 2 | Older protocol needs an extra exchange |
| QUIC with HTTP/3 | 1, combined | Transport and encryption set up together |
The browser treats the hint as advisory. It may skip it under memory pressure, on data saver modes or when too many connections are already open, so preconnect is an optimization, never a guarantee.
Preconnect compared with other resource hints
Preconnect differs from other resource hints in how much work it starts: it prepares the connection but downloads nothing. That distinguishes it from Preload, which fetches a specific file, and from Prefetch, which fetches a resource likely to be needed on a later navigation.
The comparison below places preconnect among the related hints.
| Hint | Work performed | Cost if unused | Best for |
|---|---|---|---|
| dns-prefetch | DNS lookup only | Very low | Many possible origins, older browsers |
| preconnect | DNS, TCP and TLS | Low to moderate | A few critical third-party origins |
| preload | Full download of one resource | Bandwidth for the file | Late-discovered critical assets |
| prefetch | Low-priority download for later | Bandwidth, idle time | Next-page resources |
| modulepreload | Download and parse of a JS module | Bandwidth and parsing | Module dependency graphs |
A frequent pattern pairs preconnect with dns-prefetch on the same origin. Browsers that support preconnect use it, and the others fall back to the cheaper DNS step. Preconnect is also superfluous for the page’s own origin, because the connection already exists after the HTML document is fetched.
Implementing preconnect correctly
Preconnect is implemented either with a link element in the head or with an HTTP Link header, and the header form lets the browser act before it parses any HTML. A typical header looks like Link: <https://cdn.example>; rel=preconnect. Servers can also send it in a 103 Early Hints response while the main page is still being generated.
The crossorigin attribute is the detail that most often breaks the hint. Browsers keep separate connection pools for anonymous and credentialed requests, so a preconnect without crossorigin does not help a font, which is always fetched in CORS anonymous mode. The result is a second, unused handshake.
The table helps decide when the attribute is needed.
| Resource on the origin | Request mode | Preconnect setting |
|---|---|---|
| Web fonts | CORS anonymous | Add crossorigin |
| Fetch or XHR without credentials | CORS anonymous | Add crossorigin |
| Classic scripts and stylesheets | No CORS | Omit crossorigin |
| Images without the attribute | No CORS | Omit crossorigin |
| Mixed resource types | Both modes | Use two hints, one with and one without |
Placement matters as well. The hint should appear as early as possible in the head, before render-blocking stylesheets and scripts, so that the browser can start the handshake while it waits for them.
Choosing which origins to preconnect
The right origins to preconnect are those that serve critical resources within the first few seconds of loading and that the browser discovers late. Good candidates are font hosts, the CDN that delivers the LCP image and an API origin whose response renders above-the-fold content.
Practitioners commonly limit preconnect to two to four origins. Each open connection consumes memory, competes for bandwidth during TLS and costs processor time for certificate verification, which on low-end phones can delay more important work. Browsers also close idle connections after a timeout, often around ten seconds, so a hint for a resource needed much later is wasted.
- Preconnect to origins needed for above-the-fold rendering.
- Use dns-prefetch instead for origins needed later or only on some pages.
- Remove hints for origins the page no longer uses after a redesign.
- Prefer self-hosting critical assets when possible, which removes the extra connection entirely.
Measuring the effect of preconnect
The effect of preconnect is measured by checking whether connection phases disappear from the critical request in a waterfall chart. In a successful case, the font or image request shows no DNS, connect or SSL segments, because those phases finished earlier.
Lab tools in Synthetic monitoring reveal this clearly, and audit tools flag both missing and unused hints. Field data from Real user monitoring then confirms whether metrics such as LCP and TTFB of third-party requests improved for actual visitors.
The table lists the warning signs that a hint is misconfigured.
| Symptom | Likely cause | Correction |
|---|---|---|
| Two connections to the same font host | Missing crossorigin attribute | Add crossorigin to the hint |
| Console warning about an unused preconnect | Origin not requested within seconds | Remove the hint or use dns-prefetch |
| No change in the waterfall | Hint placed after blocking resources | Move it to the top of the head |
| Slower start on low-end devices | Too many preconnected origins | Reduce to the most critical origins |
A non-technical view
Before a browser can fetch anything from another website, it must do some setup. It has to look up the address, knock on the door and agree on a secret handshake. Each of these steps takes a moment, and on a slow phone network the moments add up.
Preconnect is like calling ahead to a restaurant so the table is ready when you arrive. The browser does the introductions early, while it is busy with other things. Then, when the page finally asks for a font or a picture, the delivery can start right away instead of waiting.
A concrete example
A recipe website loads its hero photo from an image CDN and its typefaces from a separate font host. A waterfall test on a simulated 4G connection with a 150 ms round-trip time shows that both requests spend about 450 ms on DNS, TCP and TLS before downloading anything, and the hero photo is the page’s LCP element.
The developer adds <link rel="preconnect" href="https://img.cdn.example"> and, for the font host, a second hint with the crossorigin attribute, placing both at the top of the head. A rerun shows the connection phases completed during HTML parsing, and LCP drops from 3.1 s to about 2.6 s in lab tests.
Field data collected over the next month confirms a smaller but consistent gain for mobile visitors, and the team documents a rule to review preconnect hints at every redesign so unused ones are removed.