WP_Script_Modules::set_fetchpriority( string $id, ‘auto’|’low’|’high’ $priority ): bool

In this article

Sets the fetch priority for a script module.

Parameters

$idstringrequired
Script module identifier.
$priority‘auto’|‘low’|‘high’required
Fetch priority for the script module.

Return

bool Whether setting the fetchpriority was successful.

Source

public function set_fetchpriority( string $id, string $priority ): bool {
	if ( ! isset( $this->registered[ $id ] ) ) {
		return false;
	}

	if ( '' === $priority ) {
		$priority = 'auto';
	}

	if ( ! $this->is_valid_fetchpriority( $priority ) ) {
		_doing_it_wrong(
			__METHOD__,
			/* translators: %s: Invalid fetchpriority. */
			sprintf( __( 'Invalid fetchpriority: %s' ), $priority ),
			'6.9.0'
		);
		return false;
	}

	$this->registered[ $id ]['fetchpriority'] = $priority;
	return true;
}

Changelog

VersionDescription
6.9.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.