Search code examples
javascriptjqueryversiongoogle-cdngoogle.load

google.load is loading the old version of jquery causing versioning issues


I have these two lines of code in my web page:

    google.load("jquery", "1.7.0");
    google.load("jqueryui", "1.8.16");

And I decide to upgrade to the newer version:

    google.load("jquery", "1.8.2");
    google.load("jqueryui", "1.9.0");

Now the whole page breaks. When I inspect in Google Chrome by looking in the Sources tab I see that the old versions of the files are there. Also when I look at console for errors I get these errors:

Uncaught Error: Module: 'jquery' with version '1.8.2' not found!

Uncaught ReferenceError: $ is not defined

Uncaught ReferenceError: jQuery is not defined

Uncaught TypeError: undefined is not a function

Note: This problem is not browser specific. Also, I have upgraded in the past with no issues. Whats going on here. And how do I resolve it? Many thanks!


Solution

  • if you're only using the google object to load jQuery, then you can simply load jQuery directly and avoid any problems that has to do with the google script

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/jquery-ui.min.js" type="text/javascript"></script>
    

    in addition, jquery 1.8 is not in the Google Loader

    If you go directly to https://www.google.com/jsapi you will see at the bottom all of the supported versions and that 1.8.1 does not exist.