Skip to content

Instantly share code, notes, and snippets.

@knolaust
Created April 16, 2025 14:03
Show Gist options
  • Save knolaust/df9dc2341ff5812ede40d924865cf1f1 to your computer and use it in GitHub Desktop.
Save knolaust/df9dc2341ff5812ede40d924865cf1f1 to your computer and use it in GitHub Desktop.
Disable WP Speculative Loading
<?php
/**
* Disable Speculative Loading in WordPress
*
* WordPress 6.5+ introduces speculative loading (like prerendering and prefetching)
* to improve perceived performance by preloading likely navigation targets.
* This filter disables the feature entirely, which can be helpful if:
* - You're troubleshooting performance issues
* - You use dynamic or cache-sensitive content
* - You want full control over browser loading behavior
*
* To use: add this code to your theme's functions.php file or a custom plugin.
*/
add_filter(
'wp_speculation_rules_configuration',
function ( $config ) {
// Returning null disables all speculative loading rules.
return null;
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment