How to check if a jQuery plugin is loaded?

July 21st, 2015 Posted by Development No Comment yet

jQuery plugins are namespaces on the jQuery scope. You could run a simple check to see if the namespace exists. This is very simple and it will help you to prevent JavaScript error.

For example, let’s assume that my plugin depends on jQuery Validation plugin. To check if validation plugin is loaded I would do the following:


if(jQuery().pluginName) {
//run plugin dependent code
}else {
//jQuery plugin DOES NOT exist
}

No comments yet. You should be kind and add one!

Leave a Reply

Your email address will not be published.This is a required field!

You may use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>