Q:

Defining jquery when it's undefined

When the error $(document).ready(function(){ is undefined, this is because the jquery library is not on the page for my situation, but this error occurs since I have a small jquery plug-in on my pages to resolve an issue when jquery the library is present during a particular time of the user's session.
Besides placing the jquery library on the page when this particular error occurs, what is the solution to simply check if jquery is present or so the error does not occur on the page overall?

A:

Assuming you don't want to use jQuery universally for some reason, you can safely check if jQuery is not loaded by:
if(window.jQuery == undefined)

since accessing undefined properties of the global window object doesn't raise an error, whereas using an undeclared variable name does. (Note this assumes an unaltered undefined; you can add in var undefined; before this line if you can't make that assumption.)
Or simply:
if(typeof jQuery == 'undefined')

since typeof doesn't complain about undeclared variable names. (Specifically, according to the ECMAScript spec, typeof returns the string "undefined" when IsUnresolvableReference returns true for the given identifier.)

A:

// Only do anything if jQuery isn't defined
if (typeof jQuery == 'undefined') {

} else { // jQuery was already loaded   
   // Run your jQuery Code
};

A:

try
if (typeof jQuery == 'undefined') {  
    // jQuery is not loaded  
} else {
    // jQuery is loaded
}

Reference
you can also check if particular jQuery plugin is loaded or not.

