What Are Preconnect Resource Hints?

In this article, let’s take a look at preconnect resource hints — what they are, why and how to use them, and best practices for auditing and scaling them.

What is a preconnect?

A preconnect is a resource hint that tells the browser to make a proactive HTTP connection to a domain the browser has not yet determined needs to be made. Creating an HTTP connection takes many steps, including:

  1. Making a DNS lookup.
  2. Connecting a TCP.
  3. Negotiating a secure TLS connection.

This can take tens or even hundreds of milliseconds. Preconnecting improves performance because when the browser does realize it needs to make a connection to download a resource, that connection has already happened!

Examples and real-life case studies

Let’s see an example. The screenshot below shows a request for a CSS file from Google:

This resource is discovered later in the waterfall and an existing HTTP connection does not exist. The browser knows it needs to download this CSS file, but first it must complete a DNS lookup, then create a TCP connection, and finally negotiate an encrypted TLS connection. These add roughly 100 ms of delay that occurs before the CSS file can be requested. We can optimize this by adding a preconnect resource hint in the <head> of the HTML file, as shown below:

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

We can see the results in the waterfall screenshot below. The preconnect hint instructs the browser to proactively connect to the Google Fonts domain. When the browser later discovers the CSS file that it needs to request, a connection has already been established. This allowed the CSS file to download immediately, shifting the overall waterfall to the left:

That was great for an example, but what are some real-world examples of the benefits of preconnect?

At Splunk, we have firsthand experience. In early 2020, we worked with a major media customer which had a substantial amount of JavaScript for a variety of third-party domains. By analyzing their site and implementing resource hints such, as preconnect and preload, we improved Time-to-Interactive by 37%, from a median of 12.8 seconds down to 7.9 seconds.

Resource hints in general — and preconnects in particular — are something that all websites should consider.

How to use preconnect to improve performance

Given the impressive gains described above, I know what you must be thinking:

If preconnect resource hints improve overall performance and user experience, why don’t I preconnect to all the domains used by my website?

Unfortunately, this can hurt performance. Why? It’s simple: browsers use a lot of complex logic to decide what needs to be downloaded and when, so the page can render and be responsive for the visitor as quickly as possible. (If you want all the nerdy details, Pat Meenan has exhaustively documented and presented on it.)

A site using resource hints is essentially asking to override what operations the browser would normally perform. This can be the source of different performance issues if used carelessly.

Excessive preconnect hints

Browsers place limits on the number of HTTP connections they will maintain. Using an excessive number of preconnect resource hints will limit the browser from making connections it needs. In effect, too many preconnects can hurt performance.

A good rule of thumb is to have no more than 6-8 preconnect resource hints.

Preconnecting to an unused domain

The only thing worse than making too many preconnects, is to ask the browser to preconnect to a domain that isn’t even used! However this can be surprisingly common. Sites change where their content comes from, or they stop using a third-party provider without removing a preconnect resource hint for that domain. Preconnects to unused domains cause performance issues in two ways:

Prematurely closed preconnect

Because browsers limit the number of HTTP connects they will maintain, browsers will close an HTTP connection if no requests happen within 10 seconds. A Premature Preconnect happens when a preconnect hint tells the browser to open an HTTP connection to a domain, but no requests are sent to that domain for 10 seconds. The browser then closes this connection, only to have to make it again when it needs to request a resource from that domain. This is bad for two reasons:

Safari’s rel resource hint issue

Many sites have adopted the pattern of specifying both a preconnect hint as well as a dns-prefetch hint inside the same <link> tag, as shown below. (See our guide to DNS prefetches resource hints for a detailed discussion.)

<link rel="preconnect dns-prefetch" href="https://example.com/">

This practice started because browsers varied in which types of resource hints they supported. As of 2020, more browsers support preconnect than support DNS prefetch and all major browsers that support DNS prefetch also support preconnect.

There really is little benefit of specifying two different resource hints inside the same <link> tag, and in reality, there is a big negative in doing this. Safari only allows one resource hint to be specified in the rel attribute of a <link> tag. Specifying two hints inside the same rel attribute causes Safari to skip the <link> tag entirely and it will not attempt either resource hint.

In effect, specifying multiple resource hints disables the hint for Safari! Instead, you should just use <link rel="preconnect"> hints.

When to use preconnect hints

In general, preconnect hints should be made to:

Good examples of these include:

Once you have determined which domains should be preconnected, you still need to test it! Just because something should improve your site’s performance or experience, doesn’t mean it will. Make sure to always test to verify:

  1. Baseline your performance with synthetic tools.
  2. Implement your change.
  3. Compare the “before” and “after” performance metrics.

Best practices for preconnect resource hints

We have seen there are many benefits from using preconnect resource hints, but also many pitfalls that hurt performance if used incorrectly. This means it is important to audit how a page is using resource hints to ensure you are following all the best practices.

Automate with Splunk

This can all be overwhelming, we know! If you are looking for a more automated solution or want to do this validation at scale, you have options. Splunk Synthetic Monitoring automatically audits pages for different issues that can occur when using resource hints.

Related Articles

Software Supply Chain Security: Proven Frameworks & Tactics to Stay Ahead of Threats
Learn
9 Minute Read

Software Supply Chain Security: Proven Frameworks & Tactics to Stay Ahead of Threats

Learn how to secure your software supply chain with real-world examples, key risks, and actionable strategies to protect your code, tools, and dependencies.
From Downtime to Uptime: Monitoring Tools and Techniques for Systems, Websites, APIs, and More
Learn
6 Minute Read

From Downtime to Uptime: Monitoring Tools and Techniques for Systems, Websites, APIs, and More

Learn how to monitor websites, APIs, and infrastructure for uptime reliability with proven strategies to reduce downtime and ensure seamless performance.
Securing Devices Across Your Organization: Why Endpoint Monitoring Matters
Learn
5 Minute Read

Securing Devices Across Your Organization: Why Endpoint Monitoring Matters

Endpoint monitoring is crucial in 2023, providing real-time visibility into the security posture of all your devices — and your employees’ devices.
The Role of Prompt Engineering in Useful AI: Benefits, Techniques, and Applications for Better Prompting
Learn
6 Minute Read

The Role of Prompt Engineering in Useful AI: Benefits, Techniques, and Applications for Better Prompting

Prompt engineering isn’t about speed — it’s about getting effective AI outputs that you can use in the real world. Get all the details here.
Software Testing: Complete Beginner's Guide
Learn
8 Minute Read

Software Testing: Complete Beginner's Guide

Discover the basics of software testing, its types, benefits, and best practices to ensure reliable, secure, and user-friendly applications.
DNS Security: Today’s Most Common DNS Risks and Threats
Learn
5 Minute Read

DNS Security: Today’s Most Common DNS Risks and Threats

When 90% of businesses are victims of DNS attacks, you need to know about DNS security. Get the full story, including the top DNS risks, in this article.
The OSI Model: Understanding the Layered Approach to Network Communication
Learn
11 Minute Read

The OSI Model: Understanding the Layered Approach to Network Communication

The OSI Model is not old news...In fact, it's still in use across the entire internet today! Read on to see exactly how these 7 layers work.
What Is Extortionware? Going Beyond Ransomware
Learn
4 Minute Read

What Is Extortionware? Going Beyond Ransomware

Learn what extortionware is, how it works, its impact, and how to protect your business from data leaks and reputational damage.
Cloud Cost Management & Trends in 2026: Strategies to Optimize Your Cloud Spend
Learn
6 Minute Read

Cloud Cost Management & Trends in 2026: Strategies to Optimize Your Cloud Spend

Managing cloud costs isn’t easy. But it can be a lot simpler if you follow these expert tips and tools. Get the full story here.