# Preload likely navigations with Speculation Rules

- Check 06.25 · Performance and Core Web Vitals · Important
- Source: https://checklist-seo-geo.com/en/performance-core-web-vitals/preload-likely-navigations-speculation-rules
- Declare Speculation Rules to prefetch or prerender the next pages, exclude URLs with side effects and check the result in Chrome.
- Updated on 2026-11-27
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/performance-core-web-vitals/preload-likely-navigations-speculation-rules.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

The Speculation Rules API lets a page tell the browser which pages it may load ahead of time: either download their HTML (`prefetch`) or render them fully in an invisible tab (`prerender`). When the visitor clicks, the next page appears faster, sometimes instantly. Once this check is done, safe internal links are covered by a rule, URLs with side effects are excluded from it and your analytics do not count pages nobody ever saw.

## Why it matters

A standard navigation starts at the click: request, server wait, HTML download, then the resources. With a speculation rule, the browser does part of that work before the click, while the visitor is hovering over or touching the link.

The two actions differ in both cost and risk:

| Action | What the browser does | Cost | Risk |
|---|---|---|---|
| `prefetch` | Downloads the HTML document only, without executing it | One request to the server | Low: no JavaScript runs |
| `prerender` | Loads and renders the full page, subresources and scripts included | Memory, CPU, bandwidth | Higher: scripts run before the visit |

A rule designates its targets in two ways: a list of URLs (`urls`) or a condition applied to the links on the page (`where`, known as a document rule). The `eagerness` field sets when the speculation is triggered. According to the Chrome documentation:

| `eagerness` | Trigger in Chrome |
|---|---|
| `immediate` | As soon as the rule is read. Default for list rules |
| `eager` | On desktop, after a very brief hover; on mobile, shortly after the link enters the viewport |
| `moderate` | On desktop, after a hover of about 200 ms; on mobile, based on viewport heuristics |
| `conservative` | When the click or touch begins. Default for document rules |

As of November 2026, only Chromium-based browsers (Chrome, Edge, Opera) apply these rules in their current versions. WebKit and Mozilla are working on same-origin `prefetch`; check the status of Safari and Firefox in the MDN compatibility table, linked at the bottom of this guide. A browser that does not know the API ignores the block without raising an error.

Chrome may also decide not to preload anything (data saver or energy saver, insufficient memory, “Preload pages” setting turned off), and it caps the number of concurrent speculations.

## What it improves

- **LCP (Largest Contentful Paint, rendering of the largest visible element)**: on a prerendered page, Core Web Vitals are measured from activation, which often gives an LCP close to zero. With `prefetch`, the gain is on the document's response time. See [target an LCP of 2.5 s](https://checklist-seo-geo.com/en/performance-core-web-vitals/target-lcp-25-s-at-75th-percentile).
- **TTFB (Time to First Byte)** of internal navigations: the HTML is already there when the click happens.
- **Scope**: only navigations that start from a page of your site are affected. The first page viewed, the one reached from a search engine, gains nothing from your rules.
- **Rankings**: indirect effect. Chrome's field data includes these faster navigations, and Core Web Vitals are only one signal among many others.
- **Costs**: extra requests to the server for pages that will not all be visited. The more aggressive the `eagerness`, the higher this overhead.

## How to check

In Chrome, open DevTools, `Application` panel, `Background services > Speculative loads` section:

- the `Rules` tab lists the rule sets detected on the page, including those injected by a CMS or a CDN;
- the `Speculations` tab lists each targeted URL, the action and its status (`Not triggered`, `Ready`, `Failure` with the reason);
- the `Speculative loads` tab tells you whether the current page was itself prefetched or prerendered.

Hover over a link, check that its status changes to `Ready`, then click. Check the headers too, because the rule may come from the HTTP response:

```bash
curl -s -o /dev/null -D - https://example.com/ | grep -i "speculation-rules"
```

On the server side, speculative requests carry the `Sec-Purpose: prefetch` header (prefetch) or `Sec-Purpose: prefetch;prerender` (prerender). Add it to your access logs to measure the extra volume.

Inside a page, this test tells you whether it was prerendered:

```js
const navigation = performance.getEntriesByType('navigation')[0];
console.log(document.prerendering || navigation.activationStart > 0);
```

## How to implement

### Before you start

List the URLs that a plain GET request must never trigger ahead of time:

- logging out, switching language or currency through a link, adding to the cart through a link;
- sending a code by text message or email, counting down a quota of free articles;
- pages whose content depends on a state that has just changed (cart, account, stock).

Start with `prefetch` and `moderate` or `conservative`. Keep `prerender` for pages where you control every script. Starter block, to place in the shared template:

```html
<script type="speculationrules">
{
  "prefetch": [
    {
      "where": {
        "and": [
          { "href_matches": "/*" },
          { "not": { "href_matches": ["/deconnexion", "/panier/*", "/compte/*", "/*\\?(.+)"] } },
          { "not": { "selector_matches": ".no-prefetch, [rel~=nofollow]" } }
        ]
      },
      "eagerness": "moderate"
    }
  ]
}
</script>
```

The block must be valid JSON: one stray comma and the whole rule set is ignored. If the site sends a Content Security Policy, allow the block with the `'inline-speculation-rules'` keyword in `script-src`, or use the HTTP header described in the Apache and Nginx sections.

### Protect analytics and ads

With `prefetch`, no script runs: there is nothing to do. With `prerender`, any script not designed for this case counts a visit that may never happen. According to Chrome, Google Analytics and Google Publisher Tag already wait for activation. For everything else, delay execution:

```js
function demarrerMesure() {
  // initialize the analytics tool
}

if (document.prerendering) {
  document.addEventListener('prerenderingchange', demarrerMesure, { once: true });
} else {
  demarrerMesure();
}
```

### Cancel after a state change

A page preloaded before an add to cart or a login shows a stale state. On the response that changes that state, send `Clear-Site-Data: "prefetchCache", "prerenderCache"`: Chrome discards its pending speculations. Support for these directives is recent and specific to Chromium; check it in the Chrome documentation.

### WordPress

Versions: WordPress 6.8 and later.

Speculative loading has been built into core since WordPress 6.8: `prefetch` with `conservative` on internal links. It is disabled for logged-in users and on sites without pretty permalinks, and it ignores URLs with query parameters. A block can opt out with the `no-prefetch` or `no-prerender` CSS class.

To exclude paths or change the mode, add the following to a plugin or to the child theme's `functions.php`:

```php
add_filter('wp_speculation_rules_href_exclude_paths', function (array $paths): array {
    $paths[] = '/panier/*';
    $paths[] = '/commande/*';

    return $paths;
});

add_filter('wp_speculation_rules_configuration', function (?array $config): ?array {
    if ($config === null) {
        return null;
    }

    $config['mode'] = 'prefetch';
    $config['eagerness'] = 'moderate';

    return $config;
});
```

Returning `null` in the second filter turns the feature off. The Speculative Loading plugin from the Performance team adds a settings page and defaults to `prerender` with `moderate`: more gain, more risk for analytics scripts.

### Cloudflare

Versions: Cloudflare dashboard, all plans (Speed Brain enabled by default on the Free plan), November 2026.

Speed Brain adds a `Speculation-Rules` header to pages, pointing to a `prefetch` rule set to `conservative` on same-site links. Setting: `Speed > Settings`, `Content Optimization` section, Speed Brain toggle.

- Prefetches are served only from Cloudflare's cache and never reach the origin: without HTML caching, Speed Brain brings nothing. See [configure browser and server caching](https://checklist-seo-geo.com/en/performance-core-web-vitals/configure-browser-server-caching).
- If the origin already sends its own `Speculation-Rules` header, Cloudflare leaves it as is.
- The documentation lists other limitations (routes going through a Worker, some Content Security Policies).

### Shopify

Versions: Shopify stores with a Liquid theme, all plans, November 2026.

Since June 2025, Shopify has sent a `Speculation-Rules` header on all Liquid stores: `prefetch` set to `conservative`. The platform also sends `Clear-Site-Data` when the cart changes. To go further, add your rules to the `<head>` of `layout/theme.liquid`; they are combined with Shopify's:

```liquid
<script type="speculationrules">
{
  "prerender": [
    {
      "where": { "selector_matches": "[data-instant-navigation]" },
      "eagerness": "moderate"
    }
  ]
}
</script>
```

Then set the `data-instant-navigation` attribute on links that are very likely to be clicked, for example the product cards of a collection. Test the installed apps: those that inject tracking may count prerendered pages.

### Laravel

Versions: Laravel 11 to 13.

Paste the starter block into the Blade layout, before `</head>`, adapting the excluded paths. Laravel declares no rule by default. Check that no GET route has a side effect: logout in the starter kits goes through POST, but a signed link or a language-switching route may have one. To make a route refuse every speculative request, respond with an error, which cancels the speculation:

```php
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class RejectSpeculativeRequests
{
    public function handle(Request $request, Closure $next): Response
    {
        if ($request->headers->has('Sec-Purpose')) {
            abort(Response::HTTP_SERVICE_UNAVAILABLE);
        }

        return $next($request);
    }
}
```

### Next.js

Versions: Next.js 15 and 16 (App Router).

Navigations between pages go through the client-side router, and the `<Link>` component already prefetches visible routes in production. Speculation Rules only apply to navigations that load a new document: they are therefore only useful for plain `<a>` links or for entering the application from another site you manage.

### Nuxt

Versions: Nuxt 3 and 4.

Same logic: `<NuxtLink>` prefetches internal routes and navigation stays on the client side. An experimental option, `experimental.crossOriginPrefetch`, relies on the Speculation Rules API for links to another origin; its behavior is described on Nuxt's experimental features page.

### Astro

Versions: Astro 4.2 and later (experimental `clientPrerender` option).

Astro produces separate pages: the rules apply to them in full. The built-in prefetching uses `<link rel="prefetch">`; the experimental option switches it to Speculation Rules prerendering wherever the browser allows it:

```js
// astro.config.mjs
import { defineConfig } from 'astro/config';

export default defineConfig({
  prefetch: {
    prefetchAll: true,
    defaultStrategy: 'hover',
  },
  experimental: {
    clientPrerender: true,
  },
});
```

A link opts out with `data-astro-prefetch="false"`.

### Apache

Versions: Apache 2.4 (mod_headers), header supported by Chrome 121 and later.

The `Speculation-Rules` header saves you from touching the templates. Create `/speculation-rules.json` at the root with the JSON content of the starter block, then:

```apache
<Files "speculation-rules.json">
    ForceType application/speculationrules+json
</Files>

<IfModule mod_headers.c>
    Header set Speculation-Rules "\"/speculation-rules.json\"" "expr=%{CONTENT_TYPE} =~ m#text/html#i"
</IfModule>
```

The `application/speculationrules+json` MIME type is mandatory, as are the quotation marks around the URL.

### Nginx

Versions: Nginx 1.18 and later, header supported by Chrome 121 and later.

```nginx
location = /speculation-rules.json {
    types { }
    default_type application/speculationrules+json;
}

add_header Speculation-Rules '"/speculation-rules.json"';
```

Place `add_header` in the `location` block that serves the HTML: an `add_header` directive in a child block cancels those inherited from the parent. Reload with `sudo nginx -t && sudo systemctl reload nginx`.

## Common mistakes

- **Prerendering the whole site with `immediate`**: server load multiplied, and Chrome caps the number of speculations anyway.
- **Forgetting links with side effects**: a hover is then enough to log the visitor out or fill their cart.
- **Switching to `prerender` without testing third-party scripts**: inflated page views and ad impressions. See [limit third-party scripts](https://checklist-seo-geo.com/en/performance-core-web-vitals/limit-third-party-scripts).
- **Stacking rules without knowing it**: WordPress core, a plugin, Speed Brain and the theme all add up. The `Rules` tab shows everything that applies.
- **Counting on the rules for the arrival from Google**: they only act on the navigations that follow. Going back relies on a different mechanism: [make pages eligible for the bfcache](https://checklist-seo-geo.com/en/performance-core-web-vitals/make-pages-eligible-bfcache).

## Frequently asked questions

### Should I choose prefetch or prerender?

Start with prefetch. It downloads only the HTML document, without running any script: the risk is limited to URLs where the request alone has a side effect. Prerender renders the whole page and gives the fastest navigations, but it runs your scripts and third-party ones before the visit. Keep it for links that are very likely to be clicked, after checking your analytics tools and ads.

### Do Speculation Rules work in Safari and Firefox?

As of November 2026, Speculation Rules are only applied by Chromium-based browsers, such as Chrome, Edge and Opera, in their current versions. The WebKit and Mozilla teams are working on same-origin prefetch. Other browsers ignore the block without raising an error: you can deploy it safely, knowing that only some of your visitors benefit. Check the MDN compatibility table.

### Do Speculation Rules improve SEO?

Indirectly. Speculation Rules speed up internal navigations in Chrome, which improves the LCP measured in the field for those page views. Core Web Vitals are one ranking signal among many others, with a modest effect. The landing page reached from a search engine is not sped up by your own rules, and crawlers do not use them.

### Does preloading skew visit statistics?

With prefetch, no: no script runs until the visitor has clicked. With prerender, scripts run before the visit; an analytics tool not designed for this case then counts pages nobody ever saw. Google Analytics waits for the page to be activated. For other tools, start measuring on the prerenderingchange event when document.prerendering is true.

## Resources

- [Chrome for Developers: Prerender pages with Speculation Rules](https://developer.chrome.com/docs/web-platform/prerender-pages)
- [Chrome for Developers: Speculation Rules implementation guide](https://developer.chrome.com/docs/web-platform/implementing-speculation-rules)
- [Chrome DevTools: Debug speculation rules](https://developer.chrome.com/docs/devtools/application/debugging-speculation-rules)
- [MDN: Speculation Rules API and compatibility table](https://developer.mozilla.org/en-US/docs/Web/API/Speculation_Rules_API)
- [MDN: `<script type="speculationrules">` syntax](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/speculationrules)
- [WordPress: Speculative loading in 6.8](https://make.wordpress.org/core/2025/03/06/speculative-loading-in-6-8/)
- [Cloudflare: Speed Brain](https://developers.cloudflare.com/speed/optimization/content/speed-brain/)
- [Shopify: Speed up navigations with the Speculation Rules API](https://shopify.dev/docs/storefronts/themes/best-practices/performance/use-speculation-rules)
- [Astro: Prefetch](https://docs.astro.build/en/guides/prefetch/) and [`clientPrerender` option](https://docs.astro.build/en/reference/experimental-flags/client-prerender/)
- [Nuxt: Experimental features](https://nuxt.com/docs/4.x/guide/going-further/experimental-features)

Next steps: [make pages eligible for the bfcache](https://checklist-seo-geo.com/en/performance-core-web-vitals/make-pages-eligible-bfcache), [target an LCP of 2.5 s](https://checklist-seo-geo.com/en/performance-core-web-vitals/target-lcp-25-s-at-75th-percentile) and [analyze real-user CrUX data](https://checklist-seo-geo.com/en/performance-core-web-vitals/analyze-real-user-crux-data).
