[theme-reviewers] wp_enqueue_script

Chip Bennett chip at chipbennett.net
Wed Sep 15 14:56:15 UTC 2010


Hmm... I'm completely unfamiliar with the template_redirect hook - and, I
thought enqueueing scripts was one of the uses of wp_head()? (Learning
something new every day, I guess!)

So, should I recommend hooking into template_redirect(), or wp_footer() - or
either, or both?

Chip

On Wed, Sep 15, 2010 at 9:53 AM, Austin Matzko <austin at pressedcode.com>wrote:

> On Wed, Sep 15, 2010 at 9:49 AM, Chip Bennett <chip at chipbennett.net>
> wrote:
> > For the Theme in question, it's wrapped in the usual conditionals (e.g.
> if (
> > is_singular() && get_option( 'thread_comments' ) ) ). It's just not
> hooked
> > into anything. I'll make the suggestion to hook into wp_head().
>
> Actually the wp_head event action hook is too late to enqueue a
> script, if you want it in the header (as opposed to the footer).
> That's because the enqueued scripts are printed during wp_head with
> priority 1.  So a call to wp_enqueue_script in a function that's a
> callback on wp_head will come too late.
>
> A better place would be the template_redirect action hook.
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20100915/a5916ad2/attachment.htm>


More information about the theme-reviewers mailing list