1

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!

Barka
  • 8,764
  • 15
  • 64
  • 91

3 Answers3

3

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.

omercnet
  • 737
  • 5
  • 16
  • 1
    That does fix the problem. Therefore the issues seems to be with google loader. It has worked for me in the past however. – Barka Nov 19 '12 at 21:31
  • Yes, the reason it breaks is that it is not included in the google loader. I guess there are two different people at Google responsible for updating the cdn and updating the google loader, and it appears that, either they don't talk to each other or the one responsible for google loader has not updated his code. I assumed that if the cdn was updated, the loader was updated also. My big mistake. – Barka Nov 19 '12 at 21:37
  • You should use the google.load for google APIs, I don't see the point of loading an entire API if all you're going to use it for is load another API... spare you users the traffic and gain the maximum speed.. also notice that on the cdn page, they don't say anything about using the google loader. – omercnet Nov 19 '12 at 21:47
0

Try to take a look at your google variable and ensure the links are similar to the ones listed in here:

https://developers.google.com/speed/libraries/devguide#jquery

Jeff Noel
  • 7,500
  • 4
  • 40
  • 66
0

@note Google's api/library loader api has apparently changed somewhat since first released. Then, we were able to .load('jquery', '1.8') or .load('jqueryui', '1.9') and still get the stable edge release. Now we cannot seem to specify the revision/minor release w/any reliability - only the major eg. '1' or exact eg. '1.8.3'.

@see this page and scroll down to Versioning for specifics. It details the above and 'recommends' requesting an api's 'test version' for our development environments via wildcard eg. '1.x' in to facilitate feedback and essentially early regression testing. My tests w/two popular libraries failed w/this construct and while that documentation needs work, this may work only for google (and not 'hosted') libraries. Additionally, while requesting only '1' versions works, you'll get only very outdated versions.

@net For hosted libraries, I'm planning on dumping the google.load pattern and going w/the src="" method documented here:. Libs can will still be loaded async with tag injection or just drop the tags in before their needed if more convenient. Then, while faster from google, I'll still be backing these up w/my own copies to be loaded in case - a recommended practice.

CNSKnight
  • 567
  • 7
  • 14