Updating older jQuery

A plugin provider today told me the problem my site is having with his plugin is related to an old version of jQuery that's built into my theme. In the functions.php file I see where the default jQuery is deregistered. And in the header file, 1.6.1 is pulled in from Google. I see the current version is 1.7.1. Is there some reason why the theme wouldn't just use the current version? Must the version be manually updated in the theme?

I also see where some other plugin loads 1.7.1 from my own wp-includes folder.

How should this work?

Mike...

  • DavidM
    • DEV MAN’s Mascot

    Hi Mike,

    I'd imagine jquery 1.6.1 may have been the version available at the time of the theme's release. I'm not sure though, I'll check with some of the team over here who might have more insight as to why the standard jquery enqueue wouldn't be used. Have you checked with the theme developer on that though?

    I'd have to say it seems totally safe to change any 1.7.1 enqueues to the standard method:
    wp_enqueue_script( 'jquery' );

    Probably would be best to check with the developers for any such plugins and themes though, to see if they can see any trouble with that. Possibly they're just concerned about future jquery updates breaking their plugin or theme?

    -David

  • mikehenrysr
    • Design Lord, Child of Thor

    The plugin developer said:

    "If there are javascript elements that have been built into the theme that have not been written in noConflict mode (e.g. using $ as a shortcut for jQuery in the code), those will need to be updated to use noConflict wrappers. http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_wrappers."

    I don't know what that means but maybe the theme developer does.

    Mike...

  • DavidM
    • DEV MAN’s Mascot

    I don't quite see how that one's relevant myself, though I may be overlooking something. The "no conflict" mode just means the plugin/theme developer will have to ensure they use "jquery" rather than the shortcuts "$". But WP developers would all know to do that.

    Ultimately, I think you'll have to check with the respective theme and plugin developers on whether their plugins and themes are developed as such.

    -David

  • Mason
    • DEV MAN’s Sidekick

    Hiya Mike,

    I'm seeing that the Blogs MU theme is tagged here. Is the above in reference to this theme specifically? I'm looking at the latest version of the theme and don't see any reference to the old jquery.

    You're developer is correct, built-in javascript should use noConflict, and looking at the source code I see it in effect in the functions.php and header.php files for Blogs MU. Let's make sure we're all on the same product here and then move forward :slight_smile:

    Thanks!

  • mikehenrysr
    • Design Lord, Child of Thor

    Yes it is in reference to the Blogs-MU theme and the code I'm referring to is in header.php on line 154.

    <!-- lets use js from google -->
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script><code></code>

    In Functions.php on line 986 is where the default jquery is deregistered.

    The plugin developer said my issue was this non-standard jquery call in the header on line 154 and that I should replace that with:

    <?php wp_enqueue_script('jquery'); ?>

    Also, if you look at any of my pages, you'll see there are two jQuery scripts being loaded. BuddyStream is loading 1.7.1 and the header is loading this 1.6.1. Last night, I made it pull the 1.6.1 from my domain rather than googleapis.com trying to get their https plugin to work.

  • Mason
    • DEV MAN’s Sidekick

    Hiya Mike,

    My guess is that you're using an older version of the theme. Can I get a link to your site?

    Here's what line 154 and following has in the latest version:

    <!--[if lt IE 9]>
    <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    My bet is the theme used to call an older js for ie9 but has since switched to a more compatible version. Updating your theme to the latest will probably do the trick.

  • mikehenrysr
    • Design Lord, Child of Thor

    Interesting. When did 1.3 come out? I am running 1.2.9 and I could have sworn I was fully updated. Now today, I'm a version behind. What do you know?

    But this isn't IE specific code at all. In fact, I still wonder why the reference to an external jQuery. That's part of what started this problem. It all works fine until I start trying to create a page to accept payments. The plugin I'm using to make the call an https call is failing on that external jQuery call.

    I'll update this tonight and let you know. My site is http://leadchangegroup.com. I've got day-job things I have to do for now. Thanks. I'll follow up tonight after I can upgrade and test.

    Mike...

  • Mason
    • DEV MAN’s Sidekick

    Hiya Mike,

    1.3 is a recent (but important) update. I found the following in the changelog:

    - All styles and js scripts are now loaded in wp_enqueue_scripts() in functions.php

    Which I'm thinking is a direct fix to the issue you're having. So, I'd say update the theme and then do let us know if you have further issues. Hopefully though, this'll resolve everything for ya.

    Thanks!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.