Detect if Cordova plugin exists
For a quite simpler (and cleaner) solution, you can also use this method :
var plugins = cordova.require("cordova/plugin_list").metadata;
You'll get an object looking like that :
{
'cordova-plugin-network-information': "1.0.0",
'cordova-plugin-whitelist': "1.0.0"
}
As any normal variable, you can then check if it's defined :
if (typeof plugins['cordova-plugin-whitelist'] === "undefined")
{
// This plugin is missing
}
you can do a setTimeout for 100 ms before trying to access the plugin, and on success/failure of the plugin cancel the timeout. if the timeout triggers - the plugin is not installed.