WebTech1223411 logo WebTech1223411Web tech, read closely
Browsers

How Browser Resource Hints Speed Up Page Loading

Your hero font arrives 800 milliseconds after the HTML, the third party checkout script waits on a fresh DNS lookup, and the next page a user is about to visit loads from scratch.

A developer's monitor showing a network waterfall chart with colored bars next to a code editor

Your hero font arrives 800 milliseconds after the HTML, the third party checkout script waits on a fresh DNS lookup, and the next page a user is about to visit loads from scratch. The browser is doing exactly what it was told, discovering resources only when it reaches them. Resource hints let you tell it earlier.

This guide explains how browser resource hints work, what preconnect, dns-prefetch, preload, prefetch and modulepreload actually do inside the loading pipeline, and how to use them without making performance worse. That last part matters more than most tutorials admit.

Why the browser needs resource hints at all

When the HTML parser reads a page, it finds stylesheets, scripts and images in document order. A separate preload scanner runs ahead of the main parser and fetches obvious resources early, which already helps a lot. But some resources are invisible to it:

  • Fonts referenced inside a CSS file, discovered only after that CSS downloads and parses.
  • Background images set in CSS.
  • Scripts injected by other scripts, such as an analytics loader.
  • Connections to third party origins that start only when the first request to them is made.

Each late discovery adds a round trip, and on a mobile connection with 100 to 150 milliseconds of latency, two or three of those stack up fast. If you want the full picture of what happens before any of this, see what actually happens between typing a URL and seeing a page.

The five resource hints and what each one does

All of them are written as a link element in the document head with a rel attribute. Several can also be sent as an HTTP Link header, which lets the browser act before the HTML body even arrives.

HintWhat the browser doesBest used for
dns-prefetchResolves the domain name earlyThird party origins used later in the page
preconnectDNS lookup, TCP handshake and TLS negotiation early1 to 3 critical third party origins
preloadDownloads a specific file now at high priorityLate discovered critical resources such as fonts
modulepreloadDownloads, parses and compiles a JavaScript moduleCritical ES modules and their imports
prefetchDownloads a file at idle priority for later useResources for the likely next navigation

preconnect and dns-prefetch

A new HTTPS connection costs a DNS lookup, a TCP handshake and a TLS negotiation. On a slow network that can be 300 milliseconds or more before the first byte is even requested. Preconnect does all three in advance. Use it for origins you will definitely hit in the first few seconds, such as a font host or image CDN. If the resource is fetched in CORS mode, as fonts always are, add the crossorigin attribute to the hint, or the browser opens a second connection anyway.

Dns-prefetch is the lighter fallback. It only resolves the name, costs very little and is safe for origins you may or may not use.

preload

Preload tells the browser to fetch one specific file immediately and hold it in memory until something asks for it. You must set the as attribute, for example as set to font, style, script or image, so the browser applies the right priority and caching rules. Without it, the file can be downloaded twice.

The classic use is a web font discovered late. Preloading the one or two font files used above the fold often removes a visible flash of fallback text.

prefetch

Prefetch is about the future, not the current page. It downloads at the lowest priority when the network is idle and stores the file in the HTTP cache. If the user clicks through to the next page, it is already there. It works nicely with how browser caching decides what reloads and what stays put, since a prefetched file follows the same cache headers.

Where resource hints sit in the loading pipeline

Thinking about order helps you pick the right hint. During a typical load, the browser receives the HTML headers, begins parsing, runs the preload scanner, builds the DOM and CSSOM, then lays out and paints. Hints sent as HTTP headers act during the first step. Hints in the head act once the parser reaches them, which is still very early.

Preload and preconnect compete for the same bandwidth and connection limits as your other critical resources. That is the key to using them well: every hint takes priority from something else. In the DevTools network waterfall you can see this directly, with preloaded files moving earlier and sometimes pushing your main stylesheet later. Our guide on reading the DevTools network waterfall shows how to spot it.

The common advice to preload everything is wrong

Performance checklists often say to preload your key resources, and teams take that literally. I have audited sites with 15 or more preload tags in the head, covering fonts, every script bundle, hero images and sometimes the main stylesheet. Those pages were slower than before.

The reason is that preload does not make the network faster. It only reorders the queue. If you preload ten files, they all get high priority, which means none of them really do, and the render blocking CSS you actually needed first now shares bandwidth with an image the user cannot see yet. Chrome also warns in the console when a preloaded file is not used within a few seconds, a sign the hint wasted bandwidth.

A better rule: preload only resources that are both critical for first paint and discovered late. In practice that is usually one or two fonts and sometimes the largest contentful paint image. Limit preconnect to about three origins, because each open connection costs CPU and memory, which hurts most on low end phones.

A quick checklist for using resource hints

  1. Open the waterfall and find any critical request that starts late or waits on a new connection.
  2. For a late connection to a third party you always use, add preconnect, with crossorigin if the request is CORS.
  3. For a late critical file such as a font, add preload with the correct as value and type.
  4. For the page most users visit next, consider prefetching its main stylesheet or script.
  5. Reload and compare. If first contentful paint or largest contentful paint did not improve, remove the hint.
  6. Check the console for unused preload warnings and clean them up.

Frequently asked questions

What is the difference between preload and prefetch?

Preload fetches a resource the current page needs soon, at high priority. Prefetch fetches a resource a future page may need, at the lowest priority during idle time. Using prefetch for something the current page needs will make it arrive later, not sooner.

Should I use preconnect or dns-prefetch?

Use preconnect for one to three third party origins you will certainly request early, since it completes the full connection setup. Use dns-prefetch for other origins you might need later, since it only resolves the domain and costs almost nothing.

Do resource hints improve Core Web Vitals?

They can, mainly largest contentful paint, when they bring a late critical resource forward. Overusing them can also hurt the same metric by stealing bandwidth from more important files. Measure before and after every change.

MC
Maren Castellanos

Maren worked in cross-browser QA before editing, and knows the DevTools Network tab better than most people know their inbox. She writes about how browsers load and render pages and about the tools that show what is really happening.

More posts by Maren

More in Browsers

01doorganico 084goad 3hot8 4465456 after5internprogram ahandfulofblessings ahmadpc ahomcybersecurity allodialresources annodex antiquesandperiodcollectibles aotc asianworldkashmir beedlectrics bloggertemplatefree bluefeatheragency bodyweightsolution campaign08blog carfixadvisor catstreetcollective cbstvsports cnfanspurchasing committeeof500yearsofdignityandresistance covertopsdjs cs-kaiyuangame cuestacomunicaciontotal cxoutlet dancebetgame deskgearhub destinyvillastay detectmagazine di33 diamondsteelbuildings donmo dyanadropship emarsysfinance emimattl escapechan eskitarih evautoplay everythingweddings-orlando farmzone feedviewerapp foxstudiosscratch gamevui123 gleasongrade greetingsday hacklabasu haskell iw-kaiyun jagoanproperti jilidskripsi joltbusinessfinance juegodepokergratis juegospucca kaeru-festival latestmehndidesigns lestanzediottaviano litemagazines localcommunityhero lustrsazan mariashebets menswheels newwebstechs1 nikkit ootheday oxigenvpn plurfitness prefetial probudgetcarpetcleaning psychicmrsmartin pyaten qvantor rejoignezlogis rexzbot riselayouts ruchin rwxqsgd5 sakaltime shibiaowang shop-bot skrtips spotlesshaven strcoding tetapatrium topselller uneplanteartificielle vipertechcr wo-kygaming yamaha-mekar yeknava yoybuysheets zenunwa yamaha-mekar jilidskripsi ankertoto ankertoto ankertoto