Tags

, , , ,

To check jQuery is loaded or not we need to check existence of jQuery() / $() function in JavaScript. jQuery() or $() functions will only be defined if they are already loaded into the current document.

So to test if jQuery is loaded or not we can use 2 methods.
Method 1:

// Method 1 to check jQuery is loaded or not
if (jQuery) {
    // jQuery is loaded
} else {
    // jQuery is not loaded
}

Method 2:

// Method 2 to check jQuery is loaded or not
if (typeof jQuery == 'undefined') {
    // jQuery is not loaded
} else {
    // jQuery is loaded
}

Reference :
http://jquery-howto.blogspot.com/2009/03/check-if-jqueryjs-is-loaded.html

Advertisements