How to determine if a web page is jquery-enabled?

The best way to check if jQuery is loaded is

if (window.jQuery) {  
    // jQuery is loaded  
} else {
    // jQuery is not loaded
}

If you check using if(jQuery){}, and it isn't there, you are going to get a reference error like below, and it will break the execution of your script. By checking if the window object has a property called jQuery, if it isn't there, it will simply return undefined.

enter image description here


Run this in the console:

if (window.jQuery) { 
    console.log("Yes there's jQuery!"); 
} else { 
    console.log("Nope, it's not on this site..."); 
};

if(jQuery) //jquery object exists

jQuery isn't magic - it's essentially just a big object. You can check for it like you would any other object.

Same thing to ensure libraries within jQuery are loaded:

if(jQuery.DatePicker) //lib exists

do a check to see if the javascript object is initialised.

if(jQuery)
{
    alert('jquery active');
}