Tutorial · performance · Published 2026-08-16 · 3 min read

Speculation Rules API for prefetching and prerendering

Speculation Rules API prefetch and prerender usage, eagerness settings, support and fallback guidance.

The Speculation Rules API lets a page tell the browser which pages to prefetch or prerender before the user clicks, so navigation to a likely next page feels instant. It improves on the old <link rel="prefetch"> hints, which downloaded HTML but did not render it, and on the removed <link rel="prerender">.

Choose an eagerness

Write the rules

Rules are JSON inside a <script type="speculationrules"> block:

<script type="speculationrules">
{
  "prerender": [
    { "where": "href_matches", "hrefs": ["/shop"], "eagerness": "eager" }
  ],
  "prefetch": [
    { "where": "href_matches", "hrefs": ["/p/*"], "eagerness": "moderate" }
  ]
}
</script>

Verify and fall back

Need a website built, fixed, optimised, migrated or replaced?

This technical resource is written by CSMBAC, a small design and development studio. If you would rather hand the problem to a professional, the website service page explains how we build enquiry-ready websites.

Explore website services