I think , that we the jQUERY users, all need an official and transparent mechanism for loading the up-to-date jQUERY version.
Anyone using/developing javascript using jQUERY, has a lot of html/js files on her machine, plus “few more” on several sites. When jQery new realease comes, the same one, wants/needs to change each and every of those files , from :
1 |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript" id="JQ.1.3" ></script> |
to:
1 |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" ></script> |
Which is in essence and in reality: impossible. This is where we all should agree on generic mechanism. I suggest jsPAX usage.Where googleapis.com , needs to “play the ball” also. So, the final mechanism would work like this:
This is the ONLY js that has to be included, “ever”
1 |
<script SRC=" http://ajax.googleapis.com/ajax/libs/JQLOADER.js" TYPE="text/javascript"></script> |
JQLOADER.js contains (specially tweaked?) jsPAX code , plus the following two lines
1 2 |
$package.packageBase = 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/'; $using('jquery.min.js',function() {/* whatever here */}); |
The same mechanism can be added to the jQuery site, as (for example)
1 |
http://jquery.com/JQLOADER.JS |
All the other jQ libs/plugins should be in the same on-line folder. so that one can use them in her code,
like this:
1 2 3 4 |
$( function () { $.using('jquery.ui.js',function() {/* whatever here */}); $.using('jquery.color.js',function() {/* whatever here */}); }) |
Yes, through the “official” jQ extension ‘using()’, which works after jQ is ‘bootstrapped’ by LOADER.JS …
Of course it is the responsibility of the host of the JQLOADER.JS to keep it updated.
This is, IMHO, a safe and useful machanism for loading always the latest versions. Of course one is always
free to use standard js loading, from on-line url’s or locall folders.
Alternatively one can copy the loader to her site, and use it from there:
1 |
<script SRC=" http://veryimportantportal.com/libs/JQLOADER.js" TYPE="text/javascript"></script> |
As every other mechanism it becomes more useful as more ubiquitously it is used.
Update 2009 MAR 11
Ok, since then I changed my mind about jsPAX. Actually not as much about jsPAX as much about the whole inclusion concept vs the jQuery developers (honourable) population.
IMHO, by far the “best” (aka “ideal”) solution would be:
1 |
http://jsquery.com/latest.js |
This should be the one and only place from where the whole planet will be including jQuery latest version. With the single, good old script HTML element, with a src attribute.
As you read this everything else becomes obsolete very quickly. XmlHttpRequest is already a de-facto standard. And as a such is to be used for dynamic script inclusion, as well.
Also. Since both Google and Micro$oft have adopted jQuery, it too can be called an “standard”. Intrinsic part of the browser environment.
So: each and every browser developer will just have to include jQuery and use it, for dynamic loading afterwards:
1 2 3 4 5 6 7 |
$.getScript("http://dev.jquery.com/view/trunk/plugins/color/jquery.color.js", function(){ $("#go").click(function(){ $(".block").animate( { backgroundColor: 'pink' }, 1000) .animate( { backgroundColor: 'blue' }, 1000); }); }); |
As simple as that.