[wp-hackers] Including javascript in the footer

Philip Walton philip at philipwalton.com
Wed May 11 07:01:45 UTC 2011


On 5/10/11 11:37 PM, Otto wrote:
> If you're not deciding until midway through the page, then
> you're-doing-it-wrong (tm). You can't enqueue once scripts have
> printed in the header, due to possible dependencies. For example, if a
> script enqueued in the head depends on a script enqueued in the
> footer, then the footer script gets promoted to the header. This is
> part of the purpose of the script dependency system.
I get the script dependency issue, but in my case I know for a fact that 
no script in the head will depend on a script in the footer.

Also, if we're talking about the "right" way to do it, in my situation 
(granted you aren't seeing what I'm trying to do) I believe it's much 
more hackish and work-around-ish to move that decision to before the 
wp_enqueue_scripts hook.

I would understand doing so if WordPress were unable to add this 
functionality, but to categorically say there is no situation where it 
could be the "right" way to go seems to go against the spirit of what 
we're all trying to do.


More information about the wp-hackers mailing list