1

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?

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.

| improve this answer | |
  • Thank you both. You just helped spark an idea for giving every Wordpress user the ability to compete on page load time < 7 seconds. – Eric Leroy Dec 22 '13 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.