We might always want jquery plugin which would be used in specific page instead of getting loaded in all pages. We call that jquery plugin file in that page only and also define the function in particular html page only. But writing this code in particular page is not a good practice instead it should be in written in main javascript file which contains all the jquery functions.
If we write that function in main javascript file then we end with getting error as that plugin file is been defined in that particluar page only.
Checking if method exist
Shorthand
Replace pluginname with whatever you are calling.
Example:
If we write that function in main javascript file then we end with getting error as that plugin file is been defined in that particluar page only.
How to check if jquery plugin is loaded or not ?
Checking if method exist
if($.fn.pluginname != 'undefined'){}
Shorthand
if($.fn.pluginname){}
Replace pluginname with whatever you are calling.
Example:
if($.fn.accordion){
$("#accordion").accordion({
heightStyle: "content"
});
}