jQuery Detect Plugin Function

07 Mar 2009

To help prevent Javascript errors that stop the rest of your script working, because you’ve forgotten to include a jQuery Plugin, or you have a jQuery Plugin that may not always be within scope, you can use the typeof operator to see if a plugin exists. It’s also great for debugging. You’ll need to get the function name from the plugin file.  For example, to detect if the prettyCheckboxes plugin is included:

if(typeof jQuery.fn.prettyCheckboxes == ‘function’) {
// Javascript Code to Run here
alert(“prettyCheckboxes jQuery Plugin is installed!”);
}

Post Comment