How to check if a jquery plugin is installed or available

Tagged: jquery
Photo by Greg Rakozy
Photo by Greg Rakozy

Most Jquery plugins act a lot like functions. They are attached to the main Jquery object, so essentially all we have to do is check that the function exists and is defined.

if ($.pluginFunction) {
  // Function exists, do your plugin stuff here.
} else {
  // Plugin does not exist, use alternatives or do nothing in here.
}

Profile picture

Written by who lives and works in Wisconsin building useful things, and thinks that pineapple on pizza is okay.