[wp-hackers] Including javascript in the footer

Jan Fabry jan.fabry at monkeyman.be
Thu May 12 13:29:29 UTC 2011


On Wednesday, May 11, 2011 7:09:48 PM UTC+2, Mike Little wrote:
>
> On Wed, May 11, 2011 at 17:46, Cornelius, Gregory <gco... at bu.edu> wrote:
>
> > Sidebars are a good example of code that is not executed until the page 
> is
> > partially rendered. There is no way for a widget to know that it is going 
> to
> > be rendered before the template is partially rendered.
> >
> >
> Look into is_active_sidebar()  and wp_get_sidebars_widgets(). You can
> determine whether a a particular widget area or widget is active or not
> quite early on in the processing.
>
Will is_active_sidebar() also tell you whether the sidebar will be called by 
the current template file? If I register two sidebars but only call one of 
them in my template file (and the other one in another template file), how 
can I know this at the time wp_enqueue_scripts is fired?

I can use the trick to enqueue my script and set a dequeue callback at the 
bottom which I remove if I do render the widget, but this is 
counterintuitive to use, and will not remove dependencies - even if those 
dependencies are also set to load at the bottom. (For an example of this 
technique, see my WPSE answer: 
[ http://wordpress.stackexchange.com/questions/16208/dynamically-add-scripts-to-wp-widget-widget-method/16720#16720 
])

Greetings,

Jan Fabry


More information about the wp-hackers mailing list