What I want to achieve:

  • Change the default JS to Google's CDN --> this works

  • Move the Google CDN to the footer --> this does not work

My code:

function my_init()   
    if (!is_admin())   

        // Load a copy of jQuery from the Google API CDN  
        // The last parameter set to TRUE states that it should be loaded  
        // in the footer.  
        wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js', FALSE, '1.11.0', TRUE);  

add_action('init', 'my_init');

I read that the last "TRUE", means that it's added to the footer. It's also stated in The Codex, so it must be true. When I check my page source, however, it shows the Google CDN in the head and not in the footer, as I wanted to.

My question: what am I doing wrong and how can I fix it?

  • 2
    I could be mistaken but if any scripts ( plugin, theme, or otherwise ) is dependant on JQuery and is enqueued into the header, jquery will also be thrown into the header above that script. – Howdy_McGee Dec 29 '15 at 20:36
  • Following what @Howdy_McGee said, wordpress.org/plugins/query-monitor might show you what is dependent on 'jquery' when the scripts are rendered. Be careful that you don't have any inline scripts that require jQuery to be present. – jgraup Dec 29 '15 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.