Speculative loading in WordPress: faster navigation without risks
Speculative loading in WordPress is a feature that starts loading the next page before the visitor actually navigates to it. Since version 6.8, WordPress enables it by default on the public front end. For a business, this means faster transitions between pages without changing the design, but it also raises questions: what must never be loaded in advance, how it affects analytics, and when it is worth going beyond the default configuration.
This article explains what WordPress does on its own, how to choose between prefetch and prerender, which URLs to exclude and how to verify the change. We rely on the developer documentation of WordPress, Chrome and MDN, which we link to directly in the text.
What speculative loading does and what WordPress enables by itself
The feature is built on the Speculation Rules API, a web platform interface. Through it, a site describes rules for the browser: which links it may load in advance, whether it should only download them (prefetch) or also fully render them in a hidden tab (prerender), and how early it should do so. According to the WordPress 6.8 developer note, the default configuration is cautious:
- prefetch mode with conservative eagerness, meaning loading starts only when the user begins to click a link,
- the feature is disabled for logged-in users and on sites without “pretty” permalinks,
- URLs with query parameters (the part after the question mark) are automatically excluded from speculative loading.
The API is a progressive enhancement. According to the same note, at the time of release it was supported by Chrome, Edge and Opera; other browsers simply ignore the rules and the site works as before. MDN marks the feature as “Limited availability”, meaning it is not available in all widely used browsers.
The benefit is not theoretical, but it should not be overstated. In the note, WordPress states that sites with the Speculative Loading plugin enabled improved their Largest Contentful Paint (LCP) passing rate by approximately 1.9% at the median. This is an aggregated figure from public datasets, not a promise for any particular website.
Prefetch or prerender: a decision table
The two main choices are the mode (what is done in advance) and the eagerness level (when it is done). WordPress allows the prefetch and prerender modes and the conservative, moderate and eager levels; it does not allow the immediate level for its site-wide rule. The behaviour of the levels is described in the Chrome documentation:
| Setting | When it triggers | Benefit | Main risk |
|---|---|---|---|
| prefetch + conservative (default) | on mouse button press or touch on a link | a smaller but safe head start | almost no wasted loads |
| prefetch + moderate | on desktop after hovering over a link for about 200 ms; on mobile according to browser heuristics | a larger head start during normal browsing | more server requests that do not lead to a visit |
| prerender + moderate | same as above, but the page is also rendered, including JavaScript | navigation can be almost instant | scripts, tracking and personalisation may run without a real visit |
| prerender + eager | even earlier, according to browser heuristics | the greatest potential | the highest memory, data and server load |
In practice, the default configuration is enough for most business websites. Moving to moderate prefetch makes sense for a content site with lightweight pages. Consider prerender only after reviewing your scripts, and preferably only for selected URLs.
Practical example: a business website with an online store
Illustrative example: a small company has a WordPress site with service pages, a blog, a language switcher and a simple WooCommerce store. It wants faster transitions from the blog to the service pages and within the product catalogue.
During a link inventory, it finds the following situations, which MDN lists as risky for speculative loading:
- a link that logs the customer out of their account,
- a language switcher that stores the selected language on the server,
- adding to cart through a plain link,
- a thank-you page that records an ad conversion on the server.
Decision: the company keeps prefetch for the whole site, raises eagerness to moderate, excludes the cart, checkout, account and thank-you page, and enables prerender only for a few of the most visited service pages. It can widen the scope only after verifying its measurements.
Step-by-step implementation
1. Inventory of URLs with side effects
Look for every URL where simply opening it (a GET request) changes something: logs the user out, adds to cart, sends an SMS code, consumes an allowance or records a conversion. The WordPress developer note calls such “action URLs” an antipattern, because state changes should happen via POST. If your site or a plugin uses them, however, they must be excluded.
2. Exclusions in code or in the editor
Exclude URLs without query parameters with the wp_speculation_rules_href_exclude_paths filter. Patterns follow the URL Pattern specification and are relative to the site. For example:
add_filter( 'wp_speculation_rules_href_exclude_paths', function ( $paths ) {
$paths[] = '/cart/*';
$paths[] = '/checkout/*';
$paths[] = '/my-account/*';
return $paths;
} );
Editors can add the CSS class no-prefetch (disables speculative loading entirely) or no-prerender (disables only prerendering) to a block in the block editor. You change the eagerness and mode with the wp_speculation_rules_configuration filter; a null value disables the feature for the given request.
3. Checking analytics and scripts for prerender
With prerender, the page’s JavaScript runs too. According to the Chrome documentation, Google Analytics waits with measurement until the page is activated, but not every tool does this. Your own scripts, chat widgets, pixels and personalisation should start only after the prerenderingchange event or check the document.prerendering property.
4. Verification in the browser and on the server
Test in a logged-out window, otherwise WordPress does not output the rules. Speculative requests carry the Sec-Purpose header with the value prefetch or prefetch;prerender, so you can find them in server logs. Chrome DevTools have a dedicated view for debugging the rules, and in the console an activationStart value greater than zero confirms that the page was prerendered.
Tradeoffs to consider
Every speculative load that is not followed by a visit is an extra request. On sites without page caching, this can noticeably increase server load, and with prerender also memory and data use for the visitor. Chrome therefore limits the number of concurrent speculations and does not prerender, for example, on low-memory devices or in data saver or energy saver mode.
Another tradeoff is freshness. According to MDN, the browser keeps a prefetched page only briefly (Chrome about 5 minutes), so with rapidly changing content, such as a limited-time sale or seat booking, a visitor may see an older version.
- The benefit grows with the number of page-to-page transitions; single landing pages from ads gain less.
- A higher eagerness level means more wasted requests, so watch your logs and server performance.
- Prerender requires maintenance: every new script needs to be assessed for prerender behaviour.
Common mistakes
- Testing in a logged-in administrator account, where WordPress does not run the feature.
- Enabling prerender site-wide without checking pixels, chat widgets and A/B tests.
- Relying on query parameters to exclude everything, even though a plugin may have action URLs without parameters.
- Manually adding your own speculation rules script alongside the WordPress rule without coordination.
- Judging the benefit from a single test instead of comparing real-user data.
Checklist before changing the configuration
- WordPress is version 6.8 or newer and the site uses pretty permalinks.
- You have a list of action URLs and they are excluded with the filter or classes.
- The cart, checkout, customer account, logout and thank-you pages are excluded.
- Analytics, ad pixels and chat start only after activation when prerendering.
- The server has page caching and can handle a higher number of requests.
- You have verified the behaviour in a logged-out window, in DevTools and in the logs.
- You can quickly revert the change with the filter or by disabling the plugin.
Frequently asked questions
Do I need to install anything to enable it?
No. WordPress 6.8 and newer outputs the default rule by itself if the visitor is not logged in and the site uses pretty permalinks. The Speculative Loading plugin offers a more convenient configuration; according to the developer note, it uses prerender with moderate eagerness by default.
Will speculative loading cause duplicate hits in Google Analytics?
Prefetch alone does not run JavaScript. With prerender, Google Analytics waits for page activation according to the Chrome documentation. For other tools and your own scripts, this needs to be verified.
How do I turn the feature off completely?
With the wp_speculation_rules_configuration filter returning null. For individual links, the no-prefetch CSS class on a block is enough.
Does it also help visitors using Safari or Firefox?
Only if their browser supports the Speculation Rules API. If not, it ignores the rules and the site behaves as before, so the feature does not harm them.
How we can help
As part of our website development and maintenance, we configure speculative loading according to your site’s actual structure, including exclusions for online stores, a review of tracking scripts and verification in the logs. If you want faster page transitions on your WordPress site without risk to orders and measurement, contact us. You will find more practical guides on website management on our blog.