[wp-hackers] Including javascript in the footer

Casey Bisson casey.bisson at gmail.com
Fri May 13 04:11:38 UTC 2011


I coded around the problem here:

http://plugins.trac.wordpress.org/browser/bsuite/trunk/components/cms-widgets.php#L1966

Look for late_enqueue_script().

What I really wish is for is an option to set the async=true property when the script is actually added to the markup.

--Casey Bisson

http://MaisonBisson.com/

On May 11, 2011, at 12:01 AM, Philip Walton wrote:

> 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