WordPress 6.8 introduced a modern performance feature called speculative loading — a browser built-in mechanism that makes your site feel faster by preloading pages users are likely to visit next.
In this post, we'll break down what speculative loading is, how it works in WordPress, when (and why) you might disable or customize it, and how to take control of it using actions and filters.
What Is Speculative Loading?
Speculative loading uses a native browser feature called the Speculation Rules API to predict which internal links a user might click and preload those pages in the background.
That means when the user does click, the page may already be partially or fully loaded, resulting in a near-instant navigation.
This feature is currently supported in Chromium based browsers like Chrome, Edge, Opera, Brave.
Preloading, Prefetching, and Prerendering: The Difference.
There are 2 main strategies for resource preloading supported by the modern browsers and the Speculation Rules API, and both of them are available to you in WordPress 6.8:
🔹 Prefetch
Prefetching hints to the browser to download the HTML of a target page, but does not render it or load sub-resources like CSS, JS, or images until the user navigates there.
- ✅ Lightweight
- ✅ Safe for most pages
- ❌ Won’t eliminate all loading delays
- 🧠 Great for less critical or optional next clicks.
🔸 Prerender
Prerendering tells the browser to load and fully render the page in the background, including stylesheets, scripts, and images. If the user clicks the link, the page shows up instantly, as it’s already loaded in a hidden tab.
- ⚡ Near-instant page transitions
- ⚠️ Can consume more bandwidth and server resources
- ❌ Risky if the page includes personalized or dynamic content
- 🧠 Best for high-probability next clicks in funnels or landing pages.
Why It's Useful
- Better UX: Pages load faster, especially for repeat visits.
- No plugin required: It's built-in and lightweight.
- SEO-safe: Doesn't interfere with how search engines crawl or index your site.
Why It Might Be an Issue
There are a few cases where speculative loading could be a problem:
-
Analytics Skew
Preloading may trigger pageview hits before a user clicks, which could inflate traffic numbers.
This is a concern only for prerendering. -
Privacy Compliance
If your site loads tracking cookies or third-party scripts on preloaded pages, it could conflict with GDPR or consent requirements.
A concern for both, but more critical with prerendering. -
Server or Hosting Limits
On high-traffic sites or resource-constrained servers, preloading adds load that may not be worth it.
A concern for both, but prerendering is significantly heavier. -
Dynamic or Personalized Pages
Prerendering pages with user-specific content can lead to inconsistent or stale results.
Safe under prefetching if dynamic content is loaded by JavaScript, risky under prerendering if the dynamic content is user-specific.
How WordPress Implements It
WordPress 6.8 outputs a special <script type="speculationrules">
tag in your HTML that contains JSON rules for preloading and prerendering. Here's a real example from Akurai demo website, and you can see a similar snippet in your websites source.
<script type="speculationrules">
{
"prefetch": [
{
"source": "document",
"where": {
"and": [
{ "href_matches": "/atlanta/*" },
{
"not": {
"href_matches": [
"/atlanta/wp-*.php",
"/atlanta/wp-admin/*",
"/atlanta/wp-content/uploads/*",
"/atlanta/wp-content/*",
"/atlanta/wp-content/plugins/*",
"/atlanta/wp-content/themes/akurai/*",
"/atlanta/*\\?(.+)"
]
}
},
{
"not": {
"selector_matches": "a[rel~=\"nofollow\"]"
}
},
{
"not":{
"selector_matches": ".no-prefetch, .no-prefetch a"
}
}
]
},
"eagerness": "conservative"
}
]
}
</script>
WordPress filters out anything that shouldn't be preloaded, such as:
- Admin (and other wp-*) URLs
- Links with
rel="nofollow"
- Links having
.no-prefetch
class or having an ancestor element with the same class - Links containing query strings (e.g. search
?s=search_term
)
It all happens automatically — no action required from you.
ℹ️ Because query-string URLs are excluded by default (
"/atlanta/*\\?(.+)"
), be sure you’re using pretty permalinks to benefit from speculative loading.
Let's check the keys and their values in this example, which is the default set by WordPress.
-
prefetch: [ ... ]
- we are only prefetching resources, the specified URLs will be prefetched. -
source: "document"
- this means the rules apply to links found in the current HTML document. -
where: { ... }
- this is where you define which links to include or exclude, the syntax must follow the URL Pattern Specification. -
eagerness
- this can have 3 values:conservative
- preloading is triggered when a user starts to click on a link.moderate
- preloading is triggered when a user hovers over the linkeager
- preloading is triggered as soon as there is the slightest suggestion a user may click the link.
You should be cautious with moderate
value especially if you're prerendering pages, and you should be very careful with eager
as it can it can increase your server load significantley.
How to Customize the Rules
You can control which URLs are included in speculative loading, change the eagerness and more by using WordPress filters.
Exclude a path altogether:
add_filter( 'wp_speculation_rules_href_exclude_paths', function( $paths ) {
$paths[] = '/disclaimer/*';
return $paths;
} );
Exclude a path only for prerender mode:
add_filter( 'wp_speculation_rules_href_exclude_paths', function( $paths, $mode ) {
if ( 'prerender' === $mode ) {
$paths[] = '/disclaimer/*';
}
return $paths;
}, 10, 2 );
Change global eagerness:
add_filter( 'wp_speculation_rules_configuration', function ( $config ) {
if ( is_array( $config ) ) {
$config['eagerness'] = 'moderate';
}
return $config;
} );
Add a separate prerender rule:
add_action(
'wp_load_speculation_rules',
function ( WP_Speculation_Rules $spec ) {
$spec->add_rule( 'prerender', 'casino-pages-prerender-rule', [
'source' => 'list',
'urls' => [
'/best-casinos/',
'/casino-bonuses/',
],
'eagerness' => 'moderate',
] );
}
);
Real-World Examples
Now that we know how to customize them, let's check out some specific examples that you may apply to your website today.
Content funnels
If you have a content funnel, you can prerender the next steps.
For a funnel like this:
/how-to-choose-casino
-> /casino-bonus-types
-> /best-casino-bonuses
You can use 2 rules, one on each page:
add_action(
'wp_load_speculation_rules',
function ( WP_Speculation_Rules $spec ) {
if ( is_page( 'how-to-choose-casino' ) ) {
$spec->add_rule( 'prerender', 'funnel-step-1', [
'source' => 'list',
'urls' => ['/casino-bonus-types/'],
'eagerness' => 'moderate',
] );
}
if ( is_page( 'casino-bonus-types' ) ) {
$spec->add_rule( 'prerender', 'funnel-step-2', [
'source' => 'list',
'urls' => ['/best-casino-bonuses/'],
'eagerness' => 'moderate',
] );
}
}
);
💡 Repeat for each step of your funnel.
Organic-Traffic Monetization
On a high-traffic post, prerender your money page.
If your post is /poker-rules
and your money page is /best-poker-bonuses
, you can use a rule like this:
add_action(
'wp_load_speculation_rules',
function ( WP_Speculation_Rules $spec ) {
if ( is_page( 'poker-rules' ) ) {
$spec->add_rule( 'prerender', 'poker-to-bonuses', [
'source' => 'list',
'urls' => ['/best-poker-bonuses/'],
'eagerness' => 'eager',
] );
}
}
);
⚠️ Pay attantion to eagerness, "eager" is used in this example, evaluate it for your specific case.
Cloaked Affiliate Links
Now most themes/plugins will give you an option to add rel="nofollow"
to your affiliate links which will automatically exclude them from speculative loading. However, you may add your links manually to your blog posts or other pages where you may forget or be unable to add the rel
tag. It wouldn't hurt to explicitly exclude your affiliate links:
add_filter( 'wp_speculation_rules_href_exclude_paths', function( $paths ) {
$paths[] = '/visit/*';
return $paths;
} );
⚠️ Change the visit
path if it's different on your website.
How to Disable Speculative Loading
To disable speculative loading site-wide:
add_filter(
'wp_speculation_rules_configuration',
fn () => null
);
To disable speculative loading for a single page:
add_filter(
'wp_speculation_rules_configuration',
fn ( $config ) => is_page( 'page-path' ) ? null : $config
);
Want to See It in Action?
You can inspect your page's source and search for:
<script type="speculationrules">
If it's there, your site is using speculative loading!
You can also find detailed information such as preloaded resources, speculative loading status, initiated speculations, successes and failures in Chrome DevTools under Application → Speculative loads.
Bonus: Demo Website with Custom Rules
Visit the newly published FXT Theme demo website - https://fxt.dinomatic.com/nyc. See how near-instant those page transitions are even though there's no traditional caching on that website. Check out the page source and you can find some custom speculation rules.
Other Browser Support
Other Desktop browsers - If a browser such as Safari or Firefox, doesn't (yet) support speculative loading, it will not affect its rendering in any way.
Mobile devices - Chrome and Opera on Android, as well as Samsung Internet support it, Firefox and Safari do not.
Browsers that do not support it, they simply ignore the rules and there's no negative impact.
Final Thoughts
Speculative loading is a smart, forward-looking performance feature that can make your WordPress site feel faster — especially on modern browsers. For most WordPress sites, it works great out of the box. But if you run analytics-heavy, personalized, or high-traffic setups, it's good to know how to control it.
Whether you choose to embrace it, restrict it, or turn it off — it's another example of WordPress moving toward a faster, more modern web.
🧭 Want help customizing speculative loading for your website? Send me your use case and I'll help you write the perfect filter.