Performance, part 7 — Preconnect

As described in previous articles about performance, the time the target browser spends downloading the shared resource is often on the critical path:

The Download step in the share action timeline

This Download step looks like an atomic operation: a single GET request to the file server, with little room left for optimization. Yet one new line of code, a preconnect hint, cut the median download time by 100ms:

<link rel="preconnect" href="https://storage.googleapis.com" crossorigin>

The browser now opens the connection to the file server ahead of time: DNS lookup, TCP handshake, TLS negotiation. When the download starts, the connection is already warm.

Download duration dropping after the introduction of Preconnect
Median download duration of a shared resource by the target browser, in milliseconds
Smaller is better

This directly benefits the user experience: transfers feel even more instant.

In some cases, the preconnect hint makes no difference: