Jaap Vossers’ SharePoint Blog

June 6, 2009

Using Google Ajax Libraries API to load jQuery

Filed under: jQuery — Jaap Vossers @ 7:16 pm

Google provides a client side API (Google AJAX Libraries API) for developers to load the jQuery library on their web pages without the need to host the jQuery library on your own site. This is particularly interesting for jQuery based scripts that can be hosted in a Content Editor Web Part in SharePoint, since you can more or less “embed” the jQuery library in your script, thereby simplifying its distribution and installation processes. The CEWP version of SharePoint InstantListFilter implements this concept.

There are several other reasons why it may be a good idea to use Google’s API to load jQuery. Have a look at 3 reasons why you should let Google host jQuery for you.

Now, one thing you need to be aware of, is that your browser may start bugging you with warnings if your site runs on https. This is because it does not like having both secure (https) and non-secure (http) items on a single page.

mixedcontent

In that case, all you need to do is to load Google’s API over https as well, which should remove the non-secure item from the page.

So in your script replace this:

<script src=”http://www.google.com/jsapi”></script>

With this:

<script src=”https://www.google.com/jsapi”></script>

1 Comment »

  1. Hi Jaap,
    Great article. Do you know how this plays with Visual Studio 2008’s Rich Intellisense for JQuery? I haven’t tried it yet, but there example is source the .js locally.
    Tom
    http://blogs.msdn.com/webdevtools/archive/2008/10/28/rich-intellisense-for-jquery.aspx

    Comment by Tom Resing — September 19, 2009 @ 3:30 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress