[wp-hackers] Including javascript in the footer

John Blackbourn johnbillion+wp at gmail.com
Wed May 11 06:36:50 UTC 2011


On 11 May 2011 07:32, Philip Walton <philip at philipwalton.com> wrote:
> I've tested wp_enqueue_script() and it doesn't work if called from any
> action after 'wp_print_scripts' in a page request.

It does, but you need to coerce it a little :)

In addition to setting the 'in_footer' parameter to true when you
enqueue the script, you also need to manually call wp_print_scripts()
within wp_footer(). I don't recall why this is the case, but I suspect
you'll find a ticket and discussion of it on Trac if you have a search
around.

Further reading: http://scribu.net/wordpress/optimal-script-loading.html

John


More information about the wp-hackers mailing list