BF50 Black Friday · 50% off all plans
from $5/mo · Auto-applied ---:--:-- Claim 50% off →
Skip to content

Search Seonio

Type a keyword, domain, or paste a URL

Start free with $1 to see full results. Powered by Seonio
Web Development

Resource hints: Preload, preconnect and prefetch

Resource hints are link tags that tell the browser to connect, download or prepare something early. Use them on the few resources a page would find late.

Monthly searches · resource hints
50
Keyword research data
resource hints
Resource hints: Preload, preconnect and prefetch
Click the image to view it full size

Resource hints are <link> elements, or the matching HTTP Link headers, that tell the browser about work it can start before the page asks for it: looking up another server's address, opening a connection to it, or downloading a file. Each hint is a rel value, such as rel="preconnect" or rel="preload".

They're hints, not orders. The browser decides whether and when to act on them. Put on the right two or three resources, they shorten the wait for what the visitor sees first. Put on everything, they compete with each other and with the page's own files, and the page gets slower.

The hints once had their own W3C specification, called Resource Hints. That address now redirects to the HTML Standard, which defines them today alongside the other link types.

Which hint does what

Hint What the browser does Use it for
dns-prefetch Looks up the IP address of another origin Third-party origins you'll contact anyway
preconnect Looks up the address and opens the connection, including the TLS handshake for HTTPS Your most critical third-party origins, such as an image or font host
preload Downloads a file the current page needs, early and with a priority set by its type A file the page needs soon but the browser would find late
modulepreload Downloads, parses and compiles a JavaScript module A critical module and its dependencies
prefetch Downloads a file at low priority into the HTTP cache A file the next page on your site will need
prerender Nothing useful anymore: it's deprecated Use speculation rules instead (see below)

Two details decide a lot of choices. First, dns-prefetch and preconnect only help with other origins, because the connection to your own origin is already open. Second, preload is for the page you're on, while prefetch is for the page the visitor will probably open next.

Every hint works as an HTTP header too, which lets a server or CDN send it before the HTML arrives:

Link: <https://images.example-cdn.com>; rel="preconnect"

When a hint actually helps

Browsers already read ahead. A preload scanner looks through the HTML before the page is parsed and starts downloading the images, scripts and stylesheets it finds there. A hint adds nothing for those. It helps with what the scanner can't see:

  • fonts referenced from inside a stylesheet,
  • background images set in CSS,
  • files that a script requests,
  • a third-party origin whose exact file URLs you don't know yet (preconnect to the origin).

The most common case is the page's main image. If your Largest Contentful Paint image only appears in CSS or JavaScript, the browser finds it late. Preload it with a high fetch priority so it starts with the stylesheet:

<link rel="preconnect" href="https://images.example-cdn.com">
<link rel="preload" href="https://images.example-cdn.com/hero.webp"
      as="image" type="image/webp" fetchpriority="high">

If the image is already an <img> in the HTML, skip the preload and put fetchpriority="high" on the <img> itself. Never lazy-load it: lazy loading waits until layout confirms the image is in view, which always delays it.

For a responsive image, imagesrcset and imagesizes on the preload link mirror the srcset and sizes of the <img>, so the browser preloads the file it will actually use. See responsive images.

Fetch priority, the companion attribute

The fetchpriority attribute (high or low) works on <img>, <link> and <script>. It doesn't start anything early. It changes the order among files the browser is already loading. That matters because a preloaded image still gets a low priority on its own, and images in the HTML aren't loaded first either, since they don't block rendering.

Use high on one image, maybe two. Once several files claim to be the most important, the attribute stops helping. Use low for things like the third slide of a carousel. Chrome and Edge support it from version 102, Safari from 17.2 and Firefox from 132. web.dev

Preparing the next page: speculation rules

<link rel="prerender"> only ever worked in Chrome and no longer prerenders anything. Its replacement is the Speculation Rules API, a JSON block that asks the browser to prefetch or fully prerender documents the visitor is likely to open:

<script type="speculationrules">
{
  "prerender": [{ "source": "list", "urls": ["/pricing"] }]
}
</script>

A prerendered page can appear almost instantly. Only list pages that are safe to load without a click, so nothing that logs a visitor out, adds to a cart or counts a view that shouldn't count. Browsers without support ignore the block. For more, see prerender.

Mistakes that make pages slower

  • Preloading too much. Every high-priority file competes with the others. MDN's advice is blunt: don't preload everything, or you won't see the benefit.
  • Preloading a file the page doesn't use. The download is wasted bandwidth for the visitor.
  • Leaving out as, or crossorigin where it's needed. The as value tells the browser what the file is, so it can set priority and headers. Font and fetch preloads also need crossorigin set to match the real request, even on your own origin.
  • Preloading several formats of one image. If you preload both an AVIF and a WebP version, browsers that support both download both.
  • Preconnecting to many origins. Open connections cost resources. Keep preconnect for the critical few and use dns-prefetch for the rest.
  • Prefetching what the cache won't keep. Prefetch goes through the HTTP cache, so Cache-Control: no-store or no-cache can defeat it.

Do resource hints help SEO?

Only through speed. A hint is worth something to search because it can speed up the moment your main content appears, which is what Core Web Vitals measure, and Google says Core Web Vitals are used by its ranking systems. Google also says that chasing a perfect score just for SEO may not be the best use of your time. Google Search Central

So measure before and after. Check your field data, add one hint at a time, and keep it only if the page gets faster.

Seonio

Put it to work on your own site

Keyword research, traffic, backlinks and clustering in one place. Start with a free $1 to test, no card required.