Frank
Frank

Reputation: 323

Is there a way to know if a script was successfully loaded?

In my plugin, I use the wordpress core plupload srcipt:

function plug_enqueue_scripts() { 
   wp_enqueue_script( 'plupload-all' ); //wordpress core
}
add_action( 'admin_enqueue_scripts', 'plug_enqueue_scripts' );

Is there a way to know if the script was successfully loaded? a callback fct? A return value?

If the script fail to load, I want to include my own plupload (js and css).

thanks

Upvotes: 0

Views: 1748

Answers (1)

diggy
diggy

Reputation: 6828

You can use wp_script_is() to check the status of a script:

if( false === wp_script_is( 'plupload-all', 'enqueued' ) ){
    // script not enqueued, do stuff
}

If you want to check if the script has been actually printed use done instead of enqueued for the second param. See all accepted values in the Codex.

Upvotes: 1

Related Questions