Developer and Text Tools

Preload, Preconnect and dns-prefetch: Writing Resource Hints That Help

When to use preconnect, dns-prefetch, preload and fetchpriority, how to get as, type and crossorigin right, and how to avoid hints that slow pages down.

Saizul Amin
Saizul Amin3 Nov 2026 · 4 min read
Preload, Preconnect and dns-prefetch: Writing Resource Hints That Help

Resource hints are the shortest performance fixes on the web: one line in the head, sometimes hundreds of milliseconds saved. They are also among the easiest to get wrong. A missing attribute can make the browser download a font twice, and a long list of hints can push the files you actually need further back in the queue. This guide explains what each hint does, when it pays off, and how to build a clean set with the Preload, Preconnect and Resource Hint Builder.

The five hints in plain words

preconnect tells the browser to open a connection to another origin now: look up the domain, open TCP and complete the TLS handshake. When the first real request to that origin arrives, it can start sending immediately. On a mobile network this saves 100 to 300 ms per origin.

dns-prefetch only does the domain lookup. It is cheap, so it suits origins you will use later, such as analytics or a chat widget.

preload fetches a specific file for the current page at high priority. It is meant for things the browser would otherwise discover late: a font referenced deep inside CSS, a hero image set as a CSS background, or a stylesheet injected by script.

modulepreload is preload for JavaScript modules. It also parses and compiles the module, so later imports are ready.

prefetch fetches something for the next navigation at the lowest priority. Use it for the page a visitor will almost certainly open next, such as the checkout from a cart.

The attributes that decide whether a preload works

A preload is only useful if the later real request matches it. That is why three attributes matter:

  • as says what kind of resource it is (font, image, style, script, fetch). Without it the browser cannot set the right priority and may not reuse the response.
  • type lets browsers skip formats they cannot use, for example font/woff2 or image/avif.
  • crossorigin must match how the file will be requested. Fonts are always requested in anonymous CORS mode, even from your own domain, so a font preload without crossorigin is fetched twice.

The builder fills these for you. Type a URL ending in .woff2 and the row becomes as="font" with type="font/woff2" and crossorigin added automatically. Image preloads also accept imagesrcset and imagesizes so the browser picks the same responsive width the img tag will request.

Building the list step by step

  1. Enter your page URL. The tool uses it to catch hints that point at your own origin, which do nothing because that connection is already open.
  2. Add hints with the quick buttons (Google Fonts, Font file, LCP image, CDN origin, Late CSS, ES module, Next page) or switch to Import from HTML and paste your current head. Import lists the hints you already have and suggests new ones from third-party origins, images marked fetchpriority="high" and woff2 files in inline @font-face rules.
  3. Adjust each row: rel, URL, as, type, crossorigin, fetchpriority and, for images, srcset and sizes.
  4. Read the checks on the left and fix errors before warnings.
  5. Choose an output and copy it.

Reading the warnings

The checker flags overuse first. More than three or four preconnects compete for sockets and CPU at the exact moment your HTML is loading. More than five or six preloads all claim high priority, which means none of them really gets it. More than two fetchpriority="high" hints have the same problem.

It also flags single-row mistakes: a preload without as, a preconnect written with a path (only the origin is used), a font preloaded with credentials, a .js file preloaded as style, or a module preloaded with the classic script rel. A notice appears when you preload a file from another origin without a matching preconnect, because the connection can start even before the parser reaches the preload tag.

Choosing an output

The HTML head output is already sorted: connections first, then preloads, then prefetches. Put it near the top of the head, before stylesheets.

The Link header output does the same job over HTTP. Sent with a 103 Early Hints response, it lets the browser start fetching while your server is still building the page, which is one of the most effective speedups for server-rendered sites.

The Nginx output wraps each entry in add_header, and the React / Next.js output uses the preconnect, prefetchDNS, preload and preinit functions from react-dom, which deduplicate hints across components.

A worked example

A shop home page uses Google Fonts, a self-hosted body font, a large AVIF hero and Google Tag Manager. A sensible set is: preconnect to fonts.gstatic.com with crossorigin, preload the body font as woff2, preload the hero image with fetchpriority high and a srcset of 600 and 1200 pixel widths, and only dns-prefetch for the tag manager because analytics is not needed for the first paint. Four hints, no warnings.

Measure afterwards

Hints are predictions. After shipping, open the Network panel and confirm that the preloaded requests start early and are not repeated, and run Lighthouse to check that the "preloaded but not used" warning is absent. If a hint does not help a real metric, remove it; fewer, better hints always beat a long list.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages