WordPress and jQuery
# July 8, 2013 at 11:51 am
Your custom functions should come as late as possible, to make sure that the library and all HTML has loaded. It’s not just for WordPress, you should always do this with any site.
There’s various ways of loading the library: your own local one, the WP one, a CDN one…all have their pros and cons. I personally always use the one that comes with WP but that’s only because I’m lazy. :)# July 8, 2013 at 1:24 pm
I realise this that’s why I personally always load jquery just before the close of the body but I thought doing this with WP could be risky if plugins that rely on jquery were being loaded into the head I.e before jquery.
So my final question do you load jquery in the head or before the close of the body?
Cheers# July 8, 2013 at 2:02 pm
> Your custom functions should come as late as possible, to make sure that the library and all HTML has loaded. It’s not just for WordPress, you should always do this with any site. @Senff
I always load libraries at the bottom. The only thing that gets loaded in the `` in my projects is Modernizr. Everything else (jQuery, plugins, site.js, etc) get loading just before the closing ``.# July 8, 2013 at 2:13 pm
I too prefer @TheDoc approach. I use this technique to load jQuery at the bottom:
Then I brute force any plugins that register scripts in the head to move to the footer, below jQuery:
You must be logged in to reply to this topic.