javascript - wordpress wp_script_is done not working on custom scripts -


i'm trying load after specific script done loading. wordpress provides method detect if script loaded or not via 'wp_script_is'. when use jquery handle "done" works when use custom script handle, nothing happens. code:

function my_custom_scripts() {    wp_enqueue_script( 'custom_script_handle', '/stem_plugins/temp.js', array( 'plugins', 'jquery' ), '1.0', true ); } add_action( 'wp_enqueue_scripts', 'my_custom_scripts' );   function include_file() {   if ( wp_script_is( 'custom_script_handle', 'done' ) ) {      include('dependent_file.php');   } } add_action( 'wp_footer', 'include_file' ); 

interestingly, if use 'jquery' script handle instead of custom script handle, works. or if use custom script handle "enqueued" instead of "done" works need work "done".

my suspicion custom script hasn't been printed time run wp_script_is(), since you're using default add_action() priority of 10. adding priority greater 10 should solve issue:

add_action( 'wp_footer', 'include_file', 20 ); 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

json - Gson().fromJson(jsonResult, Myobject.class) return values in 0's -