jQuery Library Performance Alert
jQuery libraries moved to Google AJAX Libraries API
Recently I've been doing a lot Web design and development work, using the Squarespace platform, a "A fully hosted, completely managed environment for creating and maintaining a website, blog or portfolio." I like Squarespace because it is xhtml/CSS based and lets me focus on a site's content and appearance. I get great performance and never have to deal with installing and managing any Web server software. Normally ...
Last night was the exception. I was working on some site updates, and every time I refreshed a page, there was an interminable delay while the page loaded. Coincidentally, I've been experiencing intermittent short outages in my AT&T U-verse service lately, so I put this down to another AT&T problem. But it was already after midnight anyway, so after trying a few things, I finally gave up and went to bed.
This morning, all was explained, thanks to a post about a recent jQuery change on the Squarespace Community Forum, by Stuart Hobday, a Web designer in the UK who (naturally) also uses Squarespace.
jQuery is a lightweight JavaScript library that many people find extremely useful for coding site UI behaviors, because its syntax lets you focus on the relationships between JavaScript, HTML, and CSS. That is why it is now very popular among Web developers who rely on JavaScript or Ajax frameworks to animate their sites.
When a Web page contains JavaScript code that uses a library, the library code must first be downloaded to the client. jQuery has always offered Web developers two ways to do this: download the code and upload it (along with the rest of your content) from your own server, or let the page download it directly from a jQuery server located at code.jquery.com.
The first approach is ideal once your site is in production and everything is working, but while you're in development, it's convenient to be able to grab the latest library code and be sure that you'll automatically get the benefit of any recent bug fixes or enhancements. So I think a lot of developers take that approach. And I imagine that there's quite a lot of jQuery code out there, in every day use, and still relying on a download from code.jquery.com.
And here's where the performance problem arises. Yesterday, that library was relocated to ajax.googleapis.com:
code.jquery.com Redirected to Google Ajax APIs
Posted August 20th, 2009 by Mike HostetlerStarting at 10PM MT on August 20th, code.jquery.com will start redirecting (301) to ajax.googleapis.com [http://code.google.com/apis/ajaxlibs/documentation/index.html#jquery].
Immediate Impact:
- None
- Redirection will occur using 301 “Permanent Moved”
- Packed version will be replaced with minified version
Long Term:
- Migrate any sites using code.jquery.com to Google’s AJAX Libraries API
Full documentation of Google’s Ajax API are available at http://code.google.com/apis/ajaxlibs/documentation/index.html#jquery. For your convenience here are the old URLs on code.jquery.com and their new Google Ajax API counterpart:
- jquery-latest.js
- http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js
- jquery-latest.pack.js
- http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
- jquery-latest.min.js
- http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
- jquery.js
- http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js
- jquery-1.3.2.min.js
- http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
...
--for the full list, see the jQuery blog
Although the old downloads still work, it's been taking code.jquery.com a long time to issue those 301 redirects to the google library. In the meantime, your browser will sit there (probably with a message at the bottom saying "waiting for code.jquery.com" or something similar). If you see that, look in the source code, usually in the <head> section, for a jquery download that may be causing the problem. If you control the code, fix it. Otherwise call the tech support for the site and tell them what to do.
Tags: jQuery, performance, ajax, Google, download time, Performance Matters, Web performance

Reader Comments