Quantcast
Viewing all articles
Browse latest Browse all 23

Moving CDN jQuery to footer does not work?

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())   
    {  
        wp_deregister_script('jquery');  

        // 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);  

        wp_enqueue_script('jquery');  
    }  
}  
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?


Viewing all articles
Browse latest Browse all 23

Trending Articles