What Are Speculation Rules? Instant Page Loads With Prefetch and Prerender

Short answer
What are speculation rules and what do they do?
Speculation rules are a browser feature that lets a page declare, in JSON, which links the browser may fetch or fully prerender before the user clicks. As a result, the next page either waits in memory or already sits rendered in a hidden tab, so the navigation feels close to instant.
When a page appears the instant you click a link, something usually prepared it in advance. One of the cleanest ways to do that today is speculation rules: a small JSON block that tells the browser which pages a visitor will probably open next, so it can fetch or fully render them early. In this guide we explain what the rules do, how prefetch and prerender differ, where the real risks sit, and how to roll them out without corrupting your analytics.
In short, the goal is to remove the wait the visitor feels between pages. Chrome's developer documentation describes the feature as a hint and a progressive enhancement. The browser does not have to follow your rules. For example, it may skip them when memory is low, when the user turned on Save-Data, or when the user disabled page preloading in settings. So speculation rules cannot break your site; a browser without support simply ignores them and loads the page the usual way.
The feature also replaces an older technique. According to MDN, the Chrome-only prerender link hint is deprecated and never became a standard. The newer API gives you more control and is far easier to audit.
What is the difference between prefetch and prerender?
Prefetch downloads only the HTML document of the next page and keeps it in memory. Prerender goes much further: it loads the page in an invisible tab, including images, scripts and JavaScript execution. Therefore prerender feels faster, but it costs far more.
We compiled the table below from Chrome's prerender documentation and the MDN page on the Speculation Rules API.
| Criterion | Prefetch | Prerender |
|---|---|---|
| What the browser fetches | Only the document response, no subresources | Document, subresources and running JavaScript |
| Resource cost | Low | High, close to rendering a hidden iframe |
| Cross-site use | Limited, only when the user has no cookies for that site | Not possible |
| Analytics and ads risk | Server-side side effects possible | Server-side and client-side side effects possible |
| Perceived speed | Clear gain | Often an instant switch |
| Recommended use | Broadly | Selectively, for a few targets |
MDN's advice is simple: prefetch broadly, prerender sparingly. For instance, on a blog index you can prefetch every article link, but prerender only the one or two posts that most readers actually open next.
Which browsers support speculation rules?
According to Chrome's documentation, speculation rules work in Chrome and Edge, Firefox does not support them, and Safari keeps them behind a flag. MDN also marks the API as limited availability because some widely used browsers lack it. Version numbers change often, so check the current status in the official docs.
That support picture means two things for you. First, nothing breaks in unsupported browsers, because they ignore the rules. Second, the speed gain still reaches a large share of visitors, since Chromium-based browsers dominate desktop and Android traffic in the US and most global markets. Still, plan for the fact that most iPhone visitors will not see the improvement.
You can also check support in code. MDN recommends calling HTMLScriptElement.supports with the value "speculationrules". This check helps when you inject rules with JavaScript or when you want to measure how often your rules actually fire.
- Chrome and Edge: supported, details in the official docs.
- Firefox: not supported, according to Chrome's documentation.
- Safari: behind a flag, off for normal users.
- Unsupported browser: ignores the rules and loads pages normally.
How do you write a speculation rules JSON example?
You place the rules as JSON inside a script element whose type is speculationrules, or you serve a separate JSON file through an HTTP header. The JSON holds two arrays named "prefetch" and "prerender".
The most common setup is a document rule that covers your own pages but excludes risky paths such as logout and cart. Conceptually, the JSON body looks like this:
{"prerender": [{"where": {"and": [{"href_matches": "/*"}, {"not": {"href_matches": "/logout"}}, {"not": {"selector_matches": ".no-prerender"}}]}, "eagerness": "moderate"}]}
Read it in three parts. The "where" block defines which links qualify; "href_matches" holds a URL pattern, and "selector_matches" excludes links by CSS class. Finally, "eagerness" controls how early the browser acts. The paths here are only an example, so replace them with your own logout, cart and account URLs.
On the other hand, you can also pass a fixed list. A rule that uses the "urls" key with explicit addresses is a list rule. For example, if most visitors on a campaign page go on to one product page, a list rule for that single URL is enough.
Should you use list rules or document rules?
List rules prepare a few URLs you already know. Document rules match links on the page automatically, based on conditions. On large sites that change often, document rules cut maintenance work a lot.
According to Chrome's documentation, the two types also have different defaults. List rules default to "immediate" eagerness, while document rules default to "conservative". So if you write a list rule and leave eagerness empty, the browser starts preparing the page right away. On the wrong URL, that wastes bandwidth and server capacity.
- List rules: single-goal landing pages, step-by-step wizards, a "next article" link.
- Document rules: blogs, category and product listings, navigation menus on business sites.
- Both together: a broad prefetch document rule plus a list rule that prerenders one critical page.
The third pattern is the one we see work best in practice. However, decide which page counts as critical by looking at analytics data, not by gut feeling.
What do the eagerness values mean?
Eagerness tells the browser when to start preparing a link. Chrome's documentation defines four values: conservative, moderate, eager and immediate. Higher values feel faster, but they also raise the chance of wasted loads.
| Value | When it fires (per Chrome's docs) | Good fit |
|---|---|---|
| conservative | On pointer down or touch start | Risky or heavy pages |
| moderate | Short hover or pointer down on desktop; viewport heuristics on mobile | Balanced default for most business sites |
| eager | Very short hover on desktop; shortly after the link enters the viewport on mobile | A few frequently clicked links |
| immediate | As soon as the browser reads the rule | One page the user will almost certainly open |
The documentation lists millisecond thresholds as well. Because those values can change between browser versions, check the current figures in the official docs. Chrome also caps how many speculations it keeps at once and drops older ones first in, first out. In other words, setting everything to eager does not give you more speed; it mainly burns data.
Do speculation rules break analytics and ad tracking?
They can, if you set them up carelessly. A prerendered page runs JavaScript in the background, so an analytics or pixel script that does not wait may record a page view or impression before the visitor ever sees the page.
Chrome's documentation is specific here. Google Analytics, Google Publisher Tag and AdSense delay until activation by default. However, the documentation does not say that Google Tag Manager handles prerendering on its own; third-party tags inside GTM behave according to their own code. Therefore you need to test every tag separately, including Meta Pixel, chat widgets and call tracking scripts.
Prefetch looks safer, but it is not risk-free either. MDN lists URLs with server-side side effects: logout links, language switches, add-to-cart actions, sign-in flows that send a one-time code, usage counters and ad conversion tracking. If the browser requests those URLs early, a user could get signed out or receive a cart item without clicking anything.
For businesses that run paid campaigns, this matters a lot. For example, if a thank-you page fires a conversion tag during prerender, Google Ads or Meta reports show conversions that never happened, and smart bidding then learns from bad signals.
How do you protect your scripts during prerender?
The fix is to hold back any side effect until the visitor actually sees the page. Browsers give you document.prerendering and the prerenderingchange event for exactly this purpose.
According to Chrome's documentation, document.prerendering returns true while the page is prerendering. When the browser shows the page to the user, it fires prerenderingchange on the document. So you build your own counters, pixels and autoplay code with one simple logic: if the page is prerendering, wait for the event; otherwise, run right away.
- List every third-party script that runs on page load.
- Search each vendor's documentation for prerender support.
- Wrap unclear scripts in a prerenderingchange listener, or use prefetch instead of prerender on those pages.
- Exclude thank-you pages, cart and checkout steps from the rules entirely.
- After the change, compare page views and conversions in your reports for several days.
You also have a server-side safety belt. The browser sends a Sec-Purpose request header with speculative loads: "prefetch" for prefetch and "prefetch;prerender" for prerender. If your server answers those requests with a non-2xx status, the speculation does not happen.
How do speculation rules affect Core Web Vitals?
A prerendered page is already drawn when the user opens it, so metrics such as LCP can look extremely low, sometimes close to zero. According to Chrome's documentation, Core Web Vitals count from the moment of activation.
That leads to two extreme reactions. Some teams celebrate a sudden score jump; others suspect the numbers are fake. In reality the measurement is honest, because the user really sees an instant page. However, the gain only applies to prerendered navigations. A visitor who lands from Google search still experiences the landing page at its true speed.
That is why speculation rules never replace work on optimizing Largest Contentful Paint or improving Interaction to Next Paint. Our Core Web Vitals guide covers the basics. The documentation also notes that recent versions of the web-vitals library flag prerendered navigations as their own navigation type, so you can separate them in your reporting and see what truly improved.
What should you check before adding speculation rules?
First, decide which URLs are safe to load early. Pages with side effects, personalized content or rapidly changing data should stay out of the rules.
- Logout, login, password reset and any URL that sends a one-time code.
- Links that change state with a simple GET request, such as add to cart or add to wishlist.
- Language and currency switchers.
- Thank-you and conversion pages.
- Pages with live stock, seat maps or flash prices.
- Pages with heavy video, maps or chat widgets.
Next, look at the server side. Prefetch and prerender mean extra requests, and if your response times are already high, the extra load can make things worse. Our article on TTFB and server response time shows how to read that metric. Finally, if you use a Content Security Policy, MDN says inline rules need "inline-speculation-rules" or a hash or nonce in the script-src directive.
This checklist often takes longer than writing the rules. If you are building a new site, web design services that treat performance as an architecture decision from day one save you from patching problems later.
How do you set up speculation rules step by step?
The rollout stays low risk when you move in small, reversible steps. The sequence below is a general version of the flow our team follows.
- Pull the most common navigation paths from analytics: which page do visitors open after which page?
- Write down the URLs you want to exclude, based on the list above.
- In version one, use prefetch only, with "moderate" or "conservative" eagerness.
- Publish the rules on a staging site first, then confirm the requests in browser developer tools.
- Watch analytics and pixel data for several days; if nothing spikes, go live.
- In phase two, add prerender only for the one or two most clicked targets.
- Log every change with a date, so you can tie any issue to a specific rule.
You can also deliver rules from the server. According to MDN, the Speculation-Rules header points to a JSON file, and the server must send that file with the "application/speculationrules+json" MIME type. That way you manage the rules in one file without touching templates.
How do you test that the rules actually work?
The simplest test is to read navigation timing in the console on a prerendered page. According to Chrome's documentation, a non-zero activationStart value on the PerformanceNavigationTiming entry means the browser prerendered the page.
In practice, you open the page that contains the rules, hover over or press the target link, and then check activationStart for the navigation entry in the console once the target opens. If you see zero, the page loaded the normal way. In that case, review your exclusions, the browser setting and memory conditions.
The documentation also flags a trap: adding a speculationrules element by hand in the Elements panel does not register the rules. For testing, insert them from the console with JavaScript instead. Also, prerendering only runs when the "Preload pages" option is on in Chrome's performance settings.
- activationStart above zero: prerender worked.
- Request visible in the Network panel, but activationStart is zero: probably a prefetch only.
- No request at all: a rule, setting or browser support problem.
Does WordPress core include speculation rules?
Yes. According to the WordPress Performance Team's plugin page, the feature merged into WordPress 6.8, and core only prefetches by default, with conservative eagerness.
The official Speculative Loading plugin page adds more detail. If you install the plugin, the default switches to prerender with moderate eagerness. The plugin keeps the login page and admin screens out by default, and it ignores URLs that contain a nonce and links marked nofollow. By default it also runs only for logged-out visitors.
Two practical points follow. First, an up-to-date WordPress site probably already runs a cautious prefetch, so check what exists before you stack a second layer of rules on top. Second, when you move to prerender, add your cart and checkout plugin URLs to the exclusion list. The plugin also lets you block prerender on single links with a "no-prerender" class.
Which websites benefit most from speculation rules?
Multi-page sites where you can predict the next step benefit the most. Single-page apps gain less, because their navigation already happens inside the browser.
From our field experience, blogs and content sites, online stores where shoppers move from category to product, and service businesses whose visitors browse between service pages see the clearest gains. The listing-to-product flow we describe in how page speed affects ecommerce sales is an ideal candidate for a document rule.
Paid traffic is a different story. When a visitor arrives from an ad for the first time, speculation rules do not speed up that first load; they only speed up the clicks that follow. So landing page speed for Google Ads remains a separate optimization job.
Example scenario: how does a safe rollout look on a service website?
As an example scenario, picture a business site with twelve service pages, a blog and a contact form. The goal is to make moves from the menu and blog to service pages feel instant, without corrupting form conversions.
First, the team sees in analytics that most visitors go from the homepage to two specific service pages. So they write a document rule that prefetches all internal links with "moderate" eagerness, and they keep the form thank-you page, the language switcher and admin URLs out. Then they add a separate prerender rule for just those two popular service pages.
Next comes testing. The site runs a chat widget and a call tracking script, so the team checks whether those scripts open sessions during prerender. The chat widget connects even while the page is hidden, so the team wraps it in a prerenderingchange listener. As a result, the site gets fast switches and clean data.
This scenario is only an illustration. Which scripts cause trouble on your site depends entirely on the tools you use. It is a decision flow, not a promise of results.
What are the most common speculation rules mistakes?
The most common mistake is to blanket the whole site with "immediate" or "eager" prerender without thinking. That wastes visitor data and server capacity, and it pollutes your analytics.
- Leaving eagerness empty in a list rule and missing the "immediate" default.
- Forgetting to exclude logout, add-to-cart and language switch URLs.
- Never testing conversion pixels against prerender.
- Preloading personalized pages and serving stale content.
- Not realizing why the rules fail on a site with a strict CSP.
- Loading a second, conflicting rule set through a plugin on top of WordPress core.
- Claiming the site "got faster" without measuring the prerender hit rate.
Add cache confusion to that list. If you changed a rule but still see the old behavior, caching is usually the cause. Our guide on website changes not showing walks through clearing each layer, from the browser to the CDN.
How do speculation rules work with other speed techniques?
Speculation rules prepare the next page early; other techniques make each page lighter. They do not replace each other, they complement each other.
For example, a heavy JavaScript bundle still downloads and runs during prerender. Bloated code does not disappear; it just moves to the background and spends the visitor's battery and data. That is why how JavaScript affects site speed still matters. Likewise, a performance budget keeps prerendered pages at a reasonable size.
On the visual side, the View Transitions API pairs best with speculation. If you want to smooth the switch once the page opens instantly, see our guide to smooth page transitions with the View Transitions API. On the other hand, an artificial loading screen cancels the gain, so our warnings about using a preloader apply here too.
What is the difference between speculation rules and bfcache?
Speculation rules speed up forward navigation, the next page the user has not opened yet. The back/forward cache, or bfcache, restores a page the user already visited when they press back or forward. They serve different moments and work well together.
According to the bfcache article on web.dev, the browser keeps the entire page in memory, JavaScript state included, when the user leaves, and shows it again on return without any network request. So on a site with speculation rules, checking bfcache eligibility speeds up both directions of navigation.
In practice, our team keeps both topics on the same audit list. For instance, if a script blocks bfcache on a page, that page reloads from scratch when the user comes back. No matter how good your forward speculation is, visitors who move back and forth still feel that delay. In other words, think about the full navigation path instead of one technique.
How do you measure the prerender hit rate?
The hit rate shows how many of the pages you prepared users actually opened. Chrome's documentation suggests logging an event when you insert the rules and comparing it with real prerendered page views.
This measurement answers two questions. First, are the rules wasting effort? If you see many preparations but few activations, lower eagerness or narrow the target list. Second, who benefits? According to the documentation, document.referrer stays empty for address bar navigations, and that helps you separate prerenders from your own rules from the browser's own predictions.
When should you avoid speculation rules?
If your pages are personalized, change very quickly or trigger side effects through simple requests, and you cannot exclude them safely, skip speculation rules. The speed gain is not worth bad data or broken sessions.
Aggressive settings also hurt audiences on expensive or limited mobile data. According to Chrome's documentation, Save-Data and energy saver mode on low battery already block speculation, but those protections do not cover every user. So on mobile, staying with "conservative" or "moderate" is usually enough.
Finally, components that load on every page, such as a cookie banner, also load during prerender. If the banner is already slow, the first-load problem stays unsolved; our article on a cookie consent banner hurting Core Web Vitals explains how to handle it.
When should you get expert help with speculation rules?
If your site relies on ad conversions, many third-party tags, memberships or a checkout flow, plan the rollout with an expert. The hard part is not writing the rule; it is deciding what to exclude and which scripts to hold back.
As Talha Aslan and team, we treat speed and Core Web Vitals as an architecture decision when we build business websites: lean custom code, optimized images, correct caching and a clean server configuration. Analytics, Search Console and conversion tracking connect on launch day, so we can measure whether an improvement like speculation rules distorts your data. You also see every page on a test environment before it goes live.
If your current site is slow, hard to update or breaks every time you try a new speed technique, the problem is bigger than one setting. In that case, a corporate website design process that builds speed in from the start is a healthier path than endless patches. We define scope and process in a written proposal, and we make no promises about results or rankings.



