WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp script is

Description

Determine if a script has been registered, enqueued, printed, or is waiting to be printed. Very useful when registering/enqueing scripts in plugins to avoid conflicts with other plugin scripts.

Usage

<?php wp_script_is$handle$list 'enqueued' ); ?>

Parameters

$handle
(string) (required) Name of the script. Lowercase string.
Default: None
$list
(string) (optional) The list to query.
  • registered - script was registered through wp_register_script()
  • enqueued / queue - script was enqueued
  • done - script has been printed
  • to_do - script has not yet been printed
Default: enqueued

Return Values

(bool) 
True or false.

Example

   $handle = 'fluidVids.js';
   $list = 'enqueued';
     if (wp_script_is( $handle, $list )) {
       return;
     } else {
       wp_register_script( 'fluidVids.js', plugin_dir_url(__FILE__).'js/fluidvids.min.js');
       wp_enqueue_script( 'fluidVids.js' );
     }

This would check if the script named 'fluidVids.js' is enqueued. If it is enqueued, it does nothing. If it is not enqueued, the files are then registered and enqueued.

Change Log

Source File

wp_script_is() is located in wp-includes/functions.wp-scripts.php.

Related

Enqueue Styles

Enqueue Scripts

Front-End Hooks

Admin Hooks

Login Hooks

See also index of Function Reference and index of Template Tags.