wppaste
WordPress

apply_filters( 'wp_speculation_rules_configuration', \array<string, )

Since
6.8.0
Filters the way that speculation rules are configured.

Description

The Speculation Rules API is a web API that allows to automatically prefetch or prerender certain URLs on the page, which can lead to near-instant page load times. This is also referred to as speculative loading.

There are two aspects to the configuration:

  • The "mode" (whether to "prefetch" or "prerender" URLs).
  • The "eagerness" (whether to speculatively load URLs in an "eager", "moderate", or "conservative" way).

By default, the speculation rules configuration is decided by WordPress Core ("auto"). This filter can be used to force a certain configuration, which could for instance load URLs more or less eagerly.

For logged-in users or for sites that are not configured to use pretty permalinks, the default value is null, indicating that speculative loading is entirely disabled.

Compatibility

WordPress
since 6.8.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in 4 of the 5 tracked releases, added in 6.8.0.

Parameters

\array<string,
string>|null $config Associative array with 'mode' and 'eagerness' keys, or null. The default value for both of the keys is 'auto'. Other possible values for 'mode' are 'prefetch' and 'prerender'. Other possible values for 'eagerness' are 'eager', 'moderate', and 'conservative'. The value null is used to disable speculative loading entirely.

Where this hook fires · 1

  • wp-includes/speculative-loading.php:62wp_get_speculation_rules_configuration()

Source code

	 * @param array<string, string>|null $config Associative array with 'mode' and 'eagerness' keys, or `null`. The	 *                                           default value for both of the keys is 'auto'. Other possible values	 *                                           for 'mode' are 'prefetch' and 'prerender'. Other possible values for	 *                                           'eagerness' are 'eager', 'moderate', and 'conservative'. The value	 *                                           `null` is used to disable speculative loading entirely.	 */	$config = apply_filters( 'wp_speculation_rules_configuration', $config ); 	// Allow the value `null` to indicate that speculative loading is disabled.	if ( null === $config ) {		return null;	}

Changelog

Introduced in 6.8.0. Unchanged from 6.8.8 through 7.1.0.

  1. 6.8.8
  2. 6.9.7
  3. 7.0.4
  4. 7.1.0

Signature, return type and hooks compared across 4 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.