WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to test whether a script or a style was registered using wp_register_script/_style or wp_enqueue_script/_style? All functions doesn't return a value and I'm completely clueless.

I need it to switch between different functions depending on stylesheet-libraries and scripts I offer.

Thank you!

share|improve this question
up vote 43 down vote accepted

There is a function called wp_script_is( $handle, $list ). $list can be one of:

  • 'registered' -- was registered through wp_register_script()
  • 'queue' -- was enqueued through wp_enqueue_script()
  • 'done' -- has been printed
  • 'to_do' -- will be printed

Ditto all that for wp_style_is().

share|improve this answer
wow. haven't ever seen this before.. +1 – kaiser Mar 9 '11 at 14:39
@kaiser Yeah, it didn't even have docs on the Codex until I added them this morning. – Annika Backstrom Mar 9 '11 at 20:36
i also started adding stuff to the codex. Just added has_nav_menu() to conditional tags (also new for me) and a whole load of stuff to the function reference. The reference is extremly incomplete and i really wonder why so less people add stuff there... – kaiser Mar 9 '11 at 22:45
Thanks for adding this to the codex, too! – Taylor Dewey Nov 4 '11 at 17:05
This is amazing! Thanks for adding it to the codex. – CookiesForDevo Apr 19 '12 at 15:11

Check $GLOBALS['wp_scripts']->registered for scripts.


function is_enqueued_script( $script )
    return isset( $GLOBALS['wp_scripts']->registered[ $script ] );

print (int) is_enqueued_script( 'l10n' );

$GLOBALS['wp_styles']->registered works the same way.

share|improve this answer
My Hero! Thanks a lot! +1 – kaiser Mar 3 '11 at 20:32
Down voted this due lack of sanity checking, leaves the possibility for fatal errors. – Backie Mar 4 '11 at 8:49
@Backie, but you understand that this is a proof of concept? – toscho Mar 4 '11 at 11:59
wp_script_is() is a better and safer solution (Adam Backstrom` ) solution – chrisjlee Aug 4 '11 at 14:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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