designwithfocus

Page speed & performance

Prefetch vs Preload: Which Link Hint Belongs in the Head

By Design With Focus Team 7 min read
Two link tags in a document head, one marked for now and one for later

Short answer

Use preload for a file the current page will need, and prefetch for a same-site resource a later navigation is likely to need. The HTML spec says preload follows the as destination for this navigation, and prefetch is a hint the browser may delay. MDN stores a preload in a per-document memory cache and a prefetch in the HTTP cache on disk.

Last verified against the sources listed below.

Key takeaways

  • The HTML spec says preload is for the current navigation and requires an as destination.
  • Prefetch is a hint for a future navigation, and the browser may delay that fetch.
  • MDN says preload needs as, and font or fetch preloads also need crossorigin.
  • MDN keeps prefetch results in the disk HTTP cache and warns that no-store can block them.
  • Chrome's old Lighthouse preload audit was removed as of Lighthouse 13.

Prefetch vs preload is a head-tag choice between a file this page will use and a same-site file a later visit might use. Preload belongs on the current navigation. Prefetch is only a hint for what comes next.

The HTML living standard says the user agent will preload according to the as destination because the user is highly likely to need that resource now. The same standard says prefetch is likely to help a future navigation, and the browser may delay it. That split is the verdict.

Page speed is the reason these hints exist. A hint does not change the bytes. It changes when the request starts.

Side by side

The rows below follow the HTML link-type table and the MDN pages for each keyword.

Question Preload Prefetch
Spec job Current navigation, using the as destination A later navigation that is likely
Obligation in the link table Must fetch and cache Should fetch and cache
Extra attribute as is required, or the fetch stops MDN examples use only href
Where MDN says it is stored Per-document memory cache HTTP cache on disk
Delay Must not delay the load event May be delayed for the current page
Link header processing Yes, the spec preloads the header The spec says do nothing

Both keywords are body-ok, so a link may sit in the body. Both are external resource links, not hyperlinks for a.

What preload does on this page

MDN defines rel="preload" as a fetch you declare for a resource the page will need very soon, before the browser’s main rendering work. The name contains “load,” and MDN says it still does not execute a script. It downloads and caches it at a higher priority.

You set href and as. MDN lists as values of fetch, font, image, script, style, and track. The HTML processing steps translate as into a destination and return immediately if that destination is null. A preload without a usable as does not fetch.

Using as lets the browser cache the response for reuse, apply the right content security policy, and send the right Accept header. MDN also says a type attribute can skip a download the browser cannot use, which matters for an image format such as AVIF. Do not preload every format in a picture. MDN says that can download more than one file when the browser supports several types.

Fonts are the easy mistake. MDN says font and fetch preloads need crossorigin, even for a same-origin file, because the later font request uses anonymous CORS. A mismatch means the preloaded file is not the file the stylesheet asks for.

Chrome’s Lighthouse page shows a chain where index.html loads app.js, and that script then requests CSS and another script. Declaring preload links lets those files start with app.js instead of after it. The same page warns that this audit was removed as of Lighthouse 13, so treat the example as an illustration, not as a current scored audit. Its 200 millisecond figure is an example in that write-up, not a result from this guide.

If the current page never uses the preloaded URL, MDN calls that a waste. The bytes can still land in the HTTP cache when the headers allow it. That is not a reason to preload a file you only hope to need.

A smaller file is a smaller early fetch. An image compressor is the step before you mark a hero image with as="image".

What prefetch does for a later page

MDN says rel="prefetch" hints that the user is likely to need the target for a future navigation. It is for same-site documents or for subresources those pages use. The result goes into the HTTP cache on disk, so it can help a page the current document never applies.

The HTML spec’s algorithm is a should, not a must. The user agent should fetch, and it may delay that fetch so requests for the current document win. There is no default type. An empty href returns without a request.

MDN compares prefetch to fetch() with priority: "low", then says a prefetch is generally even lower priority, and that the request carries Sec-Purpose: prefetch. Sec-Fetch-Dest is empty. The Accept header matches a normal navigation so a later visit can find the cached response. A server may change cache timeouts when it sees that purpose header.

Two limits show up on the same MDN page. Cache-Control: no-cache or no-store can block the prefetch. Cache partitioning means a prefetch of https://news.example/article is not available to https://aggregator.example/. Because of those limits, MDN advises the Speculation Rules API for document prefetches where that API is supported.

This is not lazy loading. Lazy loading waits. Prefetch fetches early for a likely next page. The HTML keyword for the early current-page case is preload, which is the other half of this comparison.

The W3C Resource Hints technical report now redirects to the HTML living standard’s link types. The definitions to follow are the ones in that standard, not a separate hint list.

How does prefetch vs preload HTML differ in the head?

A preload line names the file and the destination:

<link rel="preload" href="style.css" as="style" />

A prefetch line names a likely next URL:

<link rel="prefetch" href="/landing-page" />

Those two snippets are the shapes MDN publishes. Preload can also take type, media, and crossorigin. MDN’s responsive example preloads one image when the viewport is at most 600px and another when it is wider, using media. The page still has to apply the image, because the hint only starts the fetch.

MDN’s speculative-loading guide says a preload result stays in a per-document memory cache, and that an unused preload is generally wasted. The same guide says a prefetch result stays in the disk HTTP cache, which is why it can be useful for a file the current page does not use. Browsers give prefetch a lower priority than preload because the current page matters more than the next one.

How the internet works is the fetch underneath both tags. The hint does not open a second protocol. It asks for an earlier HTTP request.

Which to choose when

Choose preload when you already know the current page needs the file and the browser would otherwise discover it late. MDN’s own examples are fonts and images referenced from CSS, and scripts a module graph would find only after another file runs. Set as, set crossorigin on a font, and add type when a MIME type would let the browser skip an unsupported file.

Choose prefetch when a same-site next page is likely, and its cache headers allow reuse. A landing page that fetches the heavier CSS and the next document is the case MDN describes. Do not prefetch a cross-site article and expect another site to read that cache entry.

Choose neither when you are guessing. A preload of an unused file spends bandwidth on this navigation, and a prefetch of a page the user does not open spends it on the next one. The spec lets the browser delay prefetch. It does not let you treat either keyword as a command the browser must finish before paint.

If the file is a module script, the HTML spec points you to modulepreload, which fills the module map. A plain preload of that script would put the result in the preload cache instead. That is a third keyword, not a tie between these two.

Frequently asked questions

How does prefetch vs preload HTML differ in the head?

Both hints are link elements. A preload link needs rel set to preload, an href, and an as value such as style, script, font, image, fetch, or track. MDN's preload examples also set type, media, or crossorigin when the later request needs them. A prefetch link in MDN's examples is only rel set to prefetch plus an href. The HTML spec says prefetch has no default type, and the fetch may be delayed so the current document's own requests come first.

Does preload run the script it downloads?

MDN says that even though the name contains load, preload does not load and execute the script. It schedules a download and a cache entry at a higher priority. The page still needs a normal script or link element to use the file. MDN shows creating a preload link in script, then later creating a script element with the same src when you actually want it to run. Module scripts are a separate hint, modulepreload, in the HTML spec.

When should you skip prefetch?

Skip it when the next URL is only a guess, or when the response cannot be reused. MDN says Cache-Control no-cache or no-store can block prefetch, and cache partitioning makes a cross-site document prefetch useless to another top-level site. The same page advises the Speculation Rules API for document prefetches where that API is supported. The HTML spec also says the browser should be allowed to delay prefetch so it does not compete with the current page.

Why does a font preload need crossorigin?

MDN says font and fetch preloads must set crossorigin so the preload uses the same CORS mode as the real request, even when the file is same-origin. Fonts are fetched in anonymous CORS mode. If the preload and the stylesheet request do not match, the browser cannot reuse the preloaded bytes. MDN's font example sets as to font, type to font/woff2, and crossorigin on the link.

Is a preload hint the same as a faster page score?

No number on the pages opened here is a guaranteed speedup. Chrome's Lighthouse write-up uses an example where a script takes 200 milliseconds, and it says the potential saving is that the later files can start with that script instead of after it. That audit page also warns the audit was removed as of Lighthouse 13. Preload only helps when the current page actually uses the file.

Sources