Forked from knolaust/disable-speculative-loading.php
Created
August 18, 2025 01:55
-
-
Save tfirdaus/c2089c58a7fb7d32098475d6c1703083 to your computer and use it in GitHub Desktop.
Disable WP Speculative Loading
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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