Summary
Resource hints, priority hints, and the Speculation Rules API let you control what the browser fetches, how urgently, and when — before the user asks for it. HTTP/2 and HTTP/3 multiplexing eliminate head-of-line blocking. Together, they shrink the critical path and hide latency behind pre-work.
Jump to the interview angleResource hints — what each one does
- `preconnect` — opens TCP+TLS to an origin early; saves ~150 ms per cold connection.
- `dns-prefetch` — resolves DNS only; cheaper than preconnect for low-priority third parties.
- `preload` — fetches a current-page resource early (LCP image, font, late script). Requires `as=` for the correct request context.
- `prefetch` — fetches a future-page resource at idle priority, stored in the HTTP cache.
- `modulepreload` — fetches, parses, and compiles an ES module graph before first import.
- `fetchpriority="high"` on the LCP `<img>` stops the browser deprioritizing it; `fetchpriority="low"` on below-fold images frees bandwidth.
Speculation Rules API — prerender and prefetch
The Speculation Rules API prerenders or prefetches entire URLs before navigation. The basic prerender API is Chromium-only; document rules (where/href_matches) and eagerness arrived later, so feature-detect rather than target a version.
<script type="speculationrules">
{
"prerender": [
{
"where": { "href_matches": "/articles/*" },
"eagerness": "moderate"
}
],
"prefetch": [
{
"urls": ["/checkout"],
"eagerness": "conservative"
}
]
}
</script>moderate triggers prerender on hover; conservative waits for mousedown. Feature-detect with HTMLScriptElement.supports('speculationrules') before injecting.
Speculation Rules is Chromium-only
As of 2026, Firefox has not shipped Speculation Rules and Safari supports it only behind a flag (off by default). Always feature-detect before injecting the script. Treat it as progressive enhancement — pages must load correctly without it.
Interview angle
Interviewers probe which hint does what and whether you know Speculation Rules browser limits. The real signal: you can rank critical-path resources and explain why prerender beats prefetch for instant navigations.
Soundbite: "Preconnect warms origins, preload unlocks early fetches, Speculation Rules prerenders the next page — Chrome only, so always feature-detect."
Key terms
- Critical path
- Resources that block first paint; shortening it cuts LCP.
- preconnect
- Opens TCP+TLS to an origin before the browser needs a resource from it.
- fetchpriority
- HTML attribute hinting high/low fetch urgency to the browser's scheduler.
- Speculation Rules API
- Chrome API to prerender or prefetch future navigations via inline JSON.
- modulepreload
- Fetches, parses, and compiles an ES module graph ahead of first import.