WordPress.org

Ready to get started?Download WordPress

Forums

Adding Latest jQuery in Functions File (1 post)

  1. ModularBase
    Member
    Posted 1 year ago #

    In researching this, I found this thread - http://wordpress.org/support/topic/linking-to-jquery-the-right-way - which demonstrates loading jQuery from Google in the header:

    function add_google_jquery() {
       if ( !is_admin() ) {
          wp_deregister_script('jquery');
          wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js', false);
          wp_enqueue_script('jquery');
       }
    }
    add_action('wp_print_scripts ', 'add_google_jquery');

    What I would like to do is always load the latest jQuery which can be obtained here: http://code.jquery.com/jquery-latest.min.js

    So, if I alter the above for the functions.php to this:

    function add_latest_jquery() {
       if ( !is_admin() ) {
          wp_deregister_script('jquery');
          wp_register_script('jquery', 'http://code.jquery.com/jquery-latest.min.js', false);
          wp_enqueue_script('jquery');
       }
    }
    add_action('wp_print_scripts ', 'add_latest_jquery');

    ...will this work in the functions.php?
    ...and is this a good idea or a not, and if not, why?

Topic Closed

This topic has been closed to new replies.

About this Topic