Checking instances of scripts in wp_head

I’m creating a plugin that uses mootools.js. I do not want multiple instances of the script installed on a user’s site, if I am able to avoid it. What is the best way to check if mootools.js is already a loaded script?

Related posts

1 comment

  1. wp_script_is() would tell you is the script is enqueued but you’d need to know the handle.

    If you really need to know if the script is enqueued you will probably have to crawl the $wp_scripts global for the actual file name.

    Try:

    global $wp_scripts;
    var_dump($wp_scripts); // after the wp_enqueue_scripts hook
    

    That will dump a huge object but the information you need is in there.

Comments are closed.