wp_script_is() WordPress Function

The wp_script_is() function is used to check whether a particular script is registered and enqueued. This function is especially useful for checking whether a script has been registered before attempting to enqueue it.

wp_script_is( string $handle, string $list = 'enqueued' ) #

Determines whether a script has been added to the queue.


Description

For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.


Top ↑

Parameters

$handle

(string)(Required)Name of the script.

$list

(string)(Optional) Status of the script to check. Accepts 'enqueued', 'registered', 'queue', 'to_do', and 'done'.

Default value: 'enqueued'


Top ↑

Return

(bool) Whether the script is queued.


Top ↑

Source

File: wp-includes/functions.wp-scripts.php

function wp_script_is( $handle, $list = 'enqueued' ) {
	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );

	return (bool) wp_scripts()->query( $handle, $list );
}


Top ↑

Changelog

Changelog
VersionDescription
3.5.0'enqueued' added as an alias of the 'queue' list.
2.8.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.