[wp-hackers] Loading scripts in WordPress

John Blackbourn johnbillion+wp at gmail.com
Tue Dec 10 22:25:20 UTC 2013


On 10 December 2013 22:20, Haluk Karamete <halukkaramete at gmail.com> wrote:

> >> you can simply call wp_enqueue_script() inside your shortcode
> callback, which will ensure that your scripts only get enqueued when the
> shortcode is parsed.
>
> That's interesting Chip. I thought that would have been too late.
> Isn't it that when the "the_content()" is running, wp_head action hook has
> already been executed?
>

If you call wp_enqueue_script() after the_header() then the script will be
enqueued in the footer. Dependencies will work as expected. (This wasn't
always the case, it was added in 3.3)

John


More information about the wp-hackers mailing list