Anybody familiar with patterns for:
- Checking for existing jQuery extension most safely?
- And how to exit from it safely if code can not be executed.
Like
(function($){
if (jQuery.fn.pluginName)
......
}
})(jQuery);
10x, BR
Anybody familiar with patterns for:
Like
(function($){
if (jQuery.fn.pluginName)
......
}
})(jQuery);
10x, BR
The $.fn namespace is populated with functions. If the plugin exists you can use this
if ($.fn.myPlugin instanceof Function) {
// the plugin exists
} else {
// the plugin does not exist
}
Also if that wasnt enough, you can also check using
if (typeof $.fn.myPlugin === 'function') {
// The plugin exists
} else {
// The plugin does not exist
}