Using javascript to check which CDN jQuery is cached on the client

Is it possible to use JavaScript to check if jQuery (cached) is loaded (already) loaded into the target web browser (user) or not? For instance:

If (JQuery-from-Microsoft-CDN-downloaded)
    Then use http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.4.js
Else if (JQuery-from-Google-APIs- downloaded)
    Then use http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
Else if (JQuery-from-code.jquery.com- downloaded)
    Then use http://code.jquery.com/jquery-1.4.4.min.js
Else use jQuery from my own website.

Means that using the javascript feature to check whether one of them is loaded on the target user (web browser), if not, then use jQuery from my own site, otherwise if true, then use the version of jQuery that is downloaded to the target user.

+5
source share
2 answers

, , . , ... , , , , -, , .

+4

, jQuery

var isLoaded = (jQuery) ? true : false;

var isLoaded = (typeof jQuery == 'undefined') ? false : true;

script , jQuery, DOM , - script, CDN

var jQueryVersion = isLoaded ? jQuery.fn.jquery : false;
0

All Articles