Some weeks ago I made a pull request for HTML5Boilerplate which should update jQuery to the latest version available on the Google CDN. How ever I copied the old version of minified jQuery because the uncompressed version was available but the minified wasn’t. Stupid thing!
That’s why I created Is Mothereffin’ jQuery up? The service checks three major CDNs for the availability of the latest jQuery version.
View Is Mothereffin’ jQuery up?
How to Check if the File is up
I had some difficulties to find the right method how to detect if a file is already available with JavaScript. If you don’t have to deal with cross-domain requests this is not a big thing and done pretty easy. But I need cross-domain requests.
If a file is not available on a server, the request dies with an error 404 and no callback will be called. See this Fiddle for a test-case. Even a try-catch
-expression does not help.
I decided to check all files for availability and if the request ends up in an error nothing will happen. The script will check if all files are available after three seconds and will otherwise “tell” the user that it’s not. This is not a bullet-proof method as it could take more then three seconds to request all files. If you have a better idea please let me know.
For the moment the resources will be labeled as “available” when they are loaded even if they were labeled “not available” before. So you will not end up with wrong result, it just may take a second more to show you that.
The Styles
The project was build “mobile-first”. It makes use of the CSS3 Flexible Box Model instead of float
and all the other stuff.
I’m not supporting IE in any way because I think most web-developer don’t use Internet Explorer.
Todo
- Support more libraries such as Mootools, Dojo, Prototype, ExtJS and YUI
- Let users submit other CDN via a form
Link buttons to their libraryDone with this commit – suggestion by Mathias
Let me know if you want some other features.
Contribute via GitHub
I’ve put this project up on GutHub. Feel free to contribute or just watch it.
Feature requests can also be placed in the issue-tracker there.