PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

how to use jquery from google's cdn

  1. obvio
    Member

    Hi,

    I'm using on my themes jquery from the google cdn, is there a way to prevent gravity from loading its own copy and use the registered and loaded one instead?

    this is how jquery is loaded in my theme:

    wp_register_script( 'jQuery-cdn', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', null, '1.7.1', false );
    wp_enqueue_script( 'jQuery-cdn' );

    I also think it looks cleaner if styles are outputted in the head section instead of in the widget itself.

    Thanks!

    Posted 12 years ago on Thursday January 5, 2012 | Permalink
  2. obvio
    Member

    solved!
    Use this in functions.php

    function my_scripts_method() {
        wp_deregister_script( 'jquery' );
        wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');
        wp_enqueue_script( 'jquery' );
    }    
    
    add_action('wp_enqueue_scripts', 'my_scripts_method');

    from http://codex.wordpress.org/Function_Reference/wp_enqueue_script

    Posted 12 years ago on Thursday January 5, 2012 | Permalink
  3. Sweet. I'm glad you figured it out and thanks too for sharing your solution. I'm sure others will be happy to use it.

    Posted 12 years ago on Thursday January 5, 2012 | Permalink

This topic has been resolved and has been closed to new replies.