Title: wp_get_speculative_loading_override
Published: August 20, 2026

---

# wp_get_speculative_loading_override( string $name ): string|null

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_get_speculative_loading_override/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_get_speculative_loading_override/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_get_speculative_loading_override/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_get_speculative_loading_override/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_get_speculative_loading_override/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_get_speculative_loading_override/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_get_speculative_loading_override/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Returns the value of a speculative loading override, as supplied by a constant or
an environment variable.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_get_speculative_loading_override/?output_format=md#description)󠁿

The constant takes precedence over the environment variable, consistent with [wp_get_environment_type()](https://developer.wordpress.org/reference/functions/wp_get_environment_type/).

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_get_speculative_loading_override/?output_format=md#parameters)󠁿

 `$name`stringrequired

Name of the constant and environment variable to look up.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_get_speculative_loading_override/?output_format=md#return)󠁿

 string|null The override value, or null if neither is set.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_get_speculative_loading_override/?output_format=md#source)󠁿

    ```php
    function wp_get_speculative_loading_override( string $name ): ?string {
    	$value = null;

    	// Check if the environment variable has been set, if `getenv` is available on the system.
    	if ( function_exists( 'getenv' ) ) {
    		$has_env = getenv( $name );
    		if ( false !== $has_env ) {
    			$value = $has_env;
    		}
    	}

    	// Fetch the value from a constant, which overrides the environment variable.
    	if ( defined( $name ) ) {
    		$has_constant = constant( $name );
    		if ( is_string( $has_constant ) ) {
    			$value = $has_constant;
    		}
    	}

    	return $value;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/speculative-loading.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/speculative-loading.php#L158)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/speculative-loading.php#L158-L178)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_get_speculative_loading_override/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_get_speculation_rules_default_configuration()](https://developer.wordpress.org/reference/functions/wp_get_speculation_rules_default_configuration/)`wp-includes/speculative-loading.php` |

Returns the default speculation rules configuration that the value ‘auto’ resolves to.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_get_speculative_loading_override/?output_format=md#changelog)󠁿

| Version | Description | 
| [7.1.0](https://developer.wordpress.org/reference/since/7.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_get_speculative_loading_override%2F)
before being able to contribute a note or feedback.