[wp-hackers] Proper handling of jquery loading.

Claude Needham gxxaxx at gmail.com
Fri Oct 21 22:00:37 UTC 2011


Thanks,

It makes sense now.
The post I was reading involved a specialized theme that did use
jquery  in its menus.

I'll let the plugins load it if they need it.

Seems like a good move for the core to load in no-conflict.

Thanks again,
Claude

On Fri, Oct 21, 2011 at 12:45 PM, Dagan Henderson
<Dagan.Henderson at epyllion.com> wrote:
> Claude,
>
> jQuery is not (and should not be) loaded at every page load. At best, loading it when it's not needed would delay uncached page loads. Some themes do make use of it, and they will no doubt include it, but unless core evolves to do something fancy enough to actually require jQuery (doubtful), you won't see it there.
>
> So, adding <?php wp_enqueue_script( 'jquery'); ?> to your header.php _before_ <?php wp_head(); ?> is called will indeed load jQuery. It should be noted, though, that WordPress loads jQuery in no-conflict mode, meaning it must be called via jQuery() and not the shorthand $().
>
> Cheers.
>
> -----Original Message-----
> From: wp-hackers-bounces at lists.automattic.com [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Claude Needham
> Sent: Friday, October 21, 2011 11:22 AM
> To: wp-hackers at lists.automattic.com
> Subject: [wp-hackers] Proper handling of jquery loading.
>
> I am trying to use the direct embed of a mailchimp form on my website.
> The reason for not using either of the two mailchimp plugins that are available is I need to include hidden fields in the form.
>
> When I embed the code (using html tab or super simple shortcode) the form does not work as expected.
>
> I figured maybe there was a javascript conflict.
>
> Did a search found an article by Chris Coyier.
> http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/
>
> In the article he made the recommendation to put a
> wp_enqueue_script("jquery") before wp_head
>
> <?php wp_enqueue_script("jquery"); ?>
> <?php wp_head(); ?>
>
> Thing is this was over 2 years ago. Seems like TwentyTen and other themes would be either following something like this. Or, more likely, the wp core has been modified to handle these issues.
>
> What is the best practice for loading jquery files?
>
> Regards,
> Claude Needham
> _______________________________________________
> 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