Title: WP_Scripts::get_eligible_loading_strategy
Published: August 8, 2023
Last modified: February 24, 2026

---

# WP_Scripts::get_eligible_loading_strategy( string $handle ): string

## In this article

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

[ Back to top](https://developer.wordpress.org/reference/classes/wp_scripts/get_eligible_loading_strategy/?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.

Gets the best eligible loading strategy for a script.

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

 `$handle`stringrequired

The script handle.

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

 string The best eligible loading strategy.

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

    ```php
    private function get_eligible_loading_strategy( $handle ) {
    	$intended_strategy = (string) $this->get_data( $handle, 'strategy' );

    	// Bail early if there is no intended strategy.
    	if ( ! $intended_strategy ) {
    		return '';
    	}

    	/*
    	 * If the intended strategy is 'defer', limit the initial list of eligible
    	 * strategies, since 'async' can fallback to 'defer', but not vice-versa.
    	 */
    	$initial_strategy = ( 'defer' === $intended_strategy ) ? array( 'defer' ) : null;

    	$eligible_strategies = $this->filter_eligible_strategies( $handle, $initial_strategy );

    	// Return early once we know the eligible strategy is blocking.
    	if ( empty( $eligible_strategies ) ) {
    		return '';
    	}

    	return in_array( 'async', $eligible_strategies, true ) ? 'async' : 'defer';
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes_class-wp-scripts-php-2/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-scripts.php#L979)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-scripts.php#L979-L1001)

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

| Uses | Description | 
| [WP_Scripts::filter_eligible_strategies()](https://developer.wordpress.org/reference/classes/wp_scripts/filter_eligible_strategies/)`wp-includes/class-wp-scripts.php` |

Filter the list of eligible loading strategies for a script.

  |

| Used by | Description | 
| [WP_Scripts::do_item()](https://developer.wordpress.org/reference/classes/wp_scripts/do_item/)`wp-includes/class-wp-scripts.php` |

Processes a script dependency.

  |

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

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

## User Contributed Notes

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