[theme-reviewers] wp_enqueue_style

Otto otto at ottodestruct.com
Fri Jun 3 11:17:29 UTC 2011


On Fri, Jun 3, 2011 at 6:02 AM, Chip Bennett <chip at chipbennett.net> wrote:
> Wait: you want to enqueue a *style* at 'wp_enqueue_scripts'? Or was that a
> typo?

No, not a typo.

There is no wp_enqueue_styles action hook, but if there was, then it
would be at the same time/place that the existing wp_enqueue_scripts
action hook is.

The reason to enqueue at that time is because that gives the rest of
the code time to potentially dequeue the script/style before it
prints. If you wait until wp_print_styles to enqueue, then the only
way you can possibly dequeue is to hook to wp_print_styles again with
a larger priority number, which is annoying and weird.

Again, enqueue early, dequeue late.

Styles and scripts destined for the front end of the site should both
be hooked into the wp_enqueue_scripts action hook.

-Otto


More information about the theme-reviewers mailing list