[theme-reviewers] wp_enqueue_style

Philip M. Hofer (Frumph) philip at frumph.net
Fri Jun 3 11:27:55 UTC 2011


Otto, it shouldn't make a difference (entirely)* when you hook it in, 
because the wp action for the wp_enqueue places it in the process at the 
appropriate time regardless. * Entirely - meaning of course use a close 
approximation for the triggering of it, after_page_load would be just a bit 
off.

You could do it at 'init' with everything else and it will still process it 
in the enqueue at the appropriate place - you just don’t want to hook it 
into the print because by that time it's a little late in the game and 
should be used for dequeue.

I would actually recommend putting wp_enqueue_(script/style) in the themes 
init location; whether it uses init or some other action location at that 
time it's best to do it when the theme itself is triggering of registered 
variables that are used throughout the theme instead of intensifying the 
codes confusion.




-----Original Message----- 
From: Otto
Sent: Friday, June 03, 2011 4:17 AM
To: theme-reviewers at lists.wordpress.org
Subject: Re: [theme-reviewers] wp_enqueue_style

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
_______________________________________________
theme-reviewers mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers 



More information about the theme-reviewers mailing list