πŸ“„
Performance

Set Up Preconnect and DNS-prefetch for a Faster Site

πŸ“… 14 October 2026 ✏️ 14 October 2026 ⏱ 5 min leestijd

Learn how to properly set up preconnect and dns-prefetch to load external resources faster and noticeably speed up your website.

Preconnect and dns-prefetch are two resource hints that let the browser prepare connections to external domains in advance, such as fonts, analytics, or CDNs. By placing these hints correctly in the head of your page, you save precious milliseconds in DNS lookup, TCP connection, and TLS handshake setup. This article shows the difference between them, when to use which hint, and how to implement them step by step.

What are preconnect and dns-prefetch

Every time a browser fetches a resource from an external domain, it has to go through several steps: a DNS lookup to find the IP address, setting up a TCP connection, and with HTTPS, also a TLS handshake. This takes time, especially if the browser only starts this process the moment the resource is actually needed.

dns-prefetch lets the browser perform the DNS lookup for a domain in advance, without making a connection. It’s lightweight and works in nearly all browsers. preconnect goes a step further: the browser not only performs the DNS lookup but also sets up the TCP connection directly and, if applicable, the TLS handshake. This makes preconnect more powerful, but also heavier on the browser if used too often.

BrowserDNS lookupTCP + TLSResource

When to use which hint

Use preconnect for domains you’re certain you’ll need right away, such as the domain hosting your fonts or a CDN serving critical CSS or scripts. Because preconnect forces the browser to actually set up connections, it’s wise to limit this to a maximum of a few domains per page. Too many preconnects actually cause delays, since the browser sets up connections that may not even be used.

Use dns-prefetch for domains you’ll probably need, but you’re not sure whether the connection will actually be used, such as tracking scripts or ad networks. Because dns-prefetch only performs name resolution, its impact on the browser is minimal, so you can safely apply it to multiple domains.

πŸ’‘ Tip: combine both techniques by adding dns-prefetch as well as preconnect for the same domain. Browsers that don’t support preconnect will then automatically fall back to the lighter dns-prefetch.

Implementation steps

1

Take stock of external domains

Check your browser’s developer tools to see which external domains are being called, such as fonts, CDNs, analytics, or embeds.

2

Choose the right hint per domain

Determine for each domain whether it’s critical for the initial render (preconnect) or only needed later (dns-prefetch).

3

Add the tags to the head

Place, for example, <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> and <link rel="dns-prefetch" href="//www.google-analytics.com"> as early as possible in the head, before other scripts.

4

Test the result

Check your browser’s network tab to see whether connections are set up earlier, and measure the load time before and after the change.

5

Check regularly

External services occasionally change domains. Keep your list of hints up to date so you don’t set up unnecessary connections to domains you no longer use.

Common mistakes

A common mistake is adding preconnect for too many domains at once. Each preconnect costs the browser processing time and memory, so with more than four or five connections it becomes counterproductive. It’s also often forgotten to add the crossorigin attribute for domains serving CORS resources, such as fonts, which means the preconnect isn’t fully utilized.

We also regularly see hints added for domains that are no longer used at all, for example after removing a script. This provides no benefit and can even cause a slight slowdown. If you manage a website through web hosting with Tandata, you can easily make these head adjustments via the file manager in Plesk, without needing to work through FTP.

Frequently asked questions

Does preconnect work in all browsers?

Most modern browsers support preconnect. Older or less common browsers fall back to a regular DNS lookup, so there’s no functional harm, just a smaller speed benefit.

Can I use preconnect for my own domain?

That’s not necessary, since the browser already has a connection to your own server once the page starts loading. Preconnect is meant for external domains.

Does this affect my email or DNS settings?

No, preconnect and dns-prefetch are purely browser techniques for page performance and have no relation to your DNS records for domains or business email.

How many domains can I preconnect?

Keep it limited to the domains that are truly critical for your page’s initial render, usually no more than a few.

Where can I find more on optimizing my website?

In the knowledge base you’ll find more articles on speed, security, and website management.

Conclusion

Preconnect and dns-prefetch are small but powerful adjustments that noticeably reduce load time for external resources. Use preconnect sparingly for critical domains and dns-prefetch more broadly for less urgent resources. Combine them wisely, test the result, and keep your list up to date for the best effect.

View web hosting β†’

Was dit artikel nuttig?