[wp-trac] [WordPress Trac] #64066: Speculative Loading: Change default eagerness from conservative to moderate when caching is detected
WordPress Trac
noreply at wordpress.org
Sun Oct 12 03:55:23 UTC 2025
#64066: Speculative Loading: Change default eagerness from conservative to moderate
when caching is detected
-------------------------------------+-------------------------------------
Reporter: westonruter | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: 6.9
Component: General | Version: 6.8
Severity: normal | Resolution:
Keywords: 2nd-opinion has-patch | Focuses: performance,
needs-unit-tests | sustainability
-------------------------------------+-------------------------------------
Comment (by westonruter):
Here's some plugin code that a host could, for example, drop into an `mu-
plugin` to enable `moderate` eagerness by default unless a plugin (e.g.
[https://wordpress.org/plugins/speculation-rules/ Speculative Loading])
had set it to be something else:
{{{#!php
<?php
add_filter(
'wp_speculation_rules_configuration',
/**
* @param array<string, string>|null|mixed $config Config.
* @return array<string, string>|null Filtered config.
*/
static function ( $config ): ?array {
// A plugin turned off Speculative Loading.
if ( null === $config ) {
return null;
}
// In case a plugin returned a bad value to a filter.
if ( ! is_array( $config ) ) {
$config = array();
}
// See <https://github.com/WordPress/wordpress-
develop/blob/e1008a31dfcf6e9c395fa7f744139d11b2c1d9a7/src/wp-includes
/speculative-loading.php#L21-L24>.
$config = array_merge(
array(
'mode' => 'auto',
'eagerness' => 'auto',
),
$config
);
// Use a default eagerness of moderate if auto remains
after all filters applied.
if ( 'auto' === $config['eagerness'] ) {
$config['eagerness'] = 'moderate';
}
return $config;
},
PHP_INT_MAX // Allow other plugins (e.g. Speculative Loading) to
easily override.
);
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64066#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list