[wp-docs] wp_enqueue_script ... "can lead to problems"

Otto otto at ottodestruct.com
Mon Jan 30 20:13:26 UTC 2012


On Mon, Jan 30, 2012 at 4:32 AM, Ghodmode <ghodmode at ghodmode.com> wrote:
> This statement is under the Usage on the
> http://codex.wordpress.org/Function_Reference/wp_enqueue_script page:
>
> '''Use the <tt>wp_enqueue_scripts</tt> action to call this function,
> or <tt>admin_enqueue_scripts</tt> to call it on the admin side.'''
> Calling it outside of an action can lead to problems. See
> [http://core.trac.wordpress.org/ticket/11526 #11526] for details.
>
> The ticket has already been fixed and there isn't any other supporting
> reason not to use wp_enqueue_script.  Also, the function is called
> directly in current themes, including twentyeleven.
>
> This statement should be removed, shouldn't it?

No, and you still shouldn't use it outside an action. twentyeleven
only uses it inside functions that are in actions, as far as I can
find.

(With one exception, that being the comment-reply script, which is
generally used in the header.php file.)

-Otto


More information about the wp-docs mailing list