Created
May 7, 2025 04:18
-
-
Save wplit/5541aaf0cac4c8fdc7889676517c8044 to your computer and use it in GitHub Desktop.
prevent speculation rules from blocking lighthouse
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 | |
add_filter('wp_speculative_loading_enabled', '__return_false'); | |
remove_action('wp_head', 'wp_output_speculationrules_script'); | |
add_action('template_redirect', function () { | |
ob_start(function ($html) { | |
return preg_replace('/<script type="speculationrules".*?<\/script>/is', '', $html); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment