[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> speculative-loading.php (summary)

Speculative loading functions.

File Size: 343 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 5 functions

  wp_get_speculation_rules_configuration()
  wp_get_speculation_rules_default_configuration()
  wp_get_speculative_loading_override()
  wp_get_speculation_rules()
  wp_print_speculation_rules()

Functions
Functions that are not part of a class:

wp_get_speculation_rules_configuration()   X-Ref
Returns the speculation rules configuration.

return: array<string, string>|null Associative array with 'mode' and 'eagerness' keys, or null if speculative

wp_get_speculation_rules_default_configuration()   X-Ref
Returns the default speculation rules configuration that the value 'auto' resolves to.

WordPress Core defaults to a mode of 'prefetch' and an eagerness of 'conservative'. Hosting providers can override
either default by way of the `WP_SPECULATIVE_LOADING_DEFAULT_MODE` and `WP_SPECULATIVE_LOADING_DEFAULT_EAGERNESS`
constants or environment variables. This only changes what the 'auto' value resolves to, so a plugin which supplies
an explicit mode or eagerness via the {@see 'wp_speculation_rules_configuration'} filter continues to take
precedence.

Note that an eagerness of 'immediate' is not permitted as a default, since WordPress does not allow it for the
document-level rules that it generates.

return: array<string, string> Associative array with 'mode' and 'eagerness' keys.

wp_get_speculative_loading_override( string $name )   X-Ref
Returns the value of a speculative loading override, as supplied by a constant or an environment variable.

The constant takes precedence over the environment variable, consistent with {@see wp_get_environment_type()}.

param: string $name Name of the constant and environment variable to look up.
return: string|null The override value, or null if neither is set.

wp_get_speculation_rules()   X-Ref
Returns the full speculation rules data based on the configuration.

Plugins with features that rely on frontend URLs to exclude from prefetching or prerendering should use the
{@see 'wp_speculation_rules_href_exclude_paths'} filter to ensure those URL patterns are excluded.

Additional speculation rules other than the default rule from WordPress Core can be provided by using the
{@see 'wp_load_speculation_rules'} action and amending the passed WP_Speculation_Rules object.

return: WP_Speculation_Rules|null Object representing the speculation rules to use, or null if speculative loading

wp_print_speculation_rules()   X-Ref
No description



Generated : Fri Jul 17 08:20:15 2026 Cross-referenced by PHPXref