When downloading javascript files from a CDN, I'd like to provide a local fallback. It's however not always obvious to me how to test if a certain load has succeeded.
For some popular things this is well documented in other StackOverflow questions, e.g. for Bootstrap one just tests if (window.jQuery)
, if (window.Popper)
, if ($.fn.modal)
for its three parts respectively. However, for other libraries this is less obvious:
- For jQuery Validate, I find conflicting information: this topic suggests one can do
if (window.validator)
, this one suggests one needsif(typeof $().validate == 'undefined')
. What is the difference between these, and why would I need one over the other? - For less popular libraries, e.g. balanceText, how should I find out if the library was loaded succesfully?
A general answer/approach would be perfect, but if that's not feasible, I'd be grateful for an answer on these two libraries.