[wp-hackers] How to enqueue default scrips in footer?
Milan Dinić
liste at srpski.biz
Fri Sep 25 21:05:54 UTC 2009
Thank you for your answers. Tynan's approach still places it in header while
Otto's make error (Call to a member function add_data() on a non-object in
...).
Maybe I didn't describe what I want. I wanted to enqueue script in footer in
frontend, not in admin.
My understanding of in_footer thing was that it will load script in footer
if there is no plugin/theme that call it in head, so if other plugin use
standard way of enqueuning (without defining in_footer), script will be
loaded in head, no matter if there are plugins which place it in footer.
But anyway, I can't place script in footer even when only that one plugin is
activated, meaning that no other plugin is enqueuning that same script.
2009/9/25 Otto <otto at ottodestruct.com>
> For default scripts, if you want to force them to the footer when
> they're not already:
>
> global $wp_scripts;
> $wp_scripts->add_data('comment-reply', 'group', 1 );
>
> Then just enqueue as per normal:
>
> wp_enqueue_script('comment-reply');
>
>
> -Otto
>
>
>
> 2009/9/25 Tynan Colin Beatty <junsuijin at gmail.com>:
> > {{{
> > global $wp_scripts;
> >
> > wp_enqueue_script(
> > 'comment-reply',
> > $wp_scripts->registered['comment-reply']->src,
> > $wp_scripts->registered['comment-reply']->deps,
> > $wp_scripts->registered['comment-reply']->ver,
> > true // print in footer
> > );
> > }}}
> >
> > it would be nice if there was a simpler approach tho. maybe this merits a
> > trac ticket.
> >
> > peace~
> >
> > On Fri, Sep 25, 2009 at 5:45 AM, scribu <scribu at gmail.com> wrote:
> >
> >> Most default scripts are included in the footer, when possible. It's
> >> usually
> >> a plugin that forces jQuery, for example, to be loaded in the head.
> >>
> >>
> >> On Fri, Sep 25, 2009 at 7:14 AM, Milan Dinić <liste at srpski.biz> wrote:
> >>
> >> > I know how to load custom scripts but what about custom ones? (
> >> >
> >> >
> >>
> http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_scripts_included_with_WordPress
> >> > )
> >> > _______________________________________________
> >> > wp-hackers mailing list
> >> > wp-hackers at lists.automattic.com
> >> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >> >
> >>
> >>
> >>
> >> --
> >> http://scribu.net
> >> _______________________________________________
> >> wp-hackers mailing list
> >> wp-hackers at lists.automattic.com
> >> http://lists.automattic.com/mailman/listinfo/wp-hackers
> >>
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list