I have some external thirdparty js files on my page, let say:
3rdparty1.js
And also I have one of my own:
myown1.js
I want to perform a condition in myown.js that asks if 3rdparty1.js is successfully loaded or not (e.g. No internet connection, error 404, suddenly third party makes 3rdparty1 private, etc.) similar to this code:
// inside myown1.js
if(3rdparty1.js_is_loaded_correctly) {
// performs function found inside 3rdparty1.js
3rdparty1function();
} else {
// performs an alternative function (maybe found inside myown.js)
myownjsbackupfunction();
// or maybe show prompt messages
alert("Some functionalities are not available at the moment."
+ " Try reloading this page later.");
}
Now, how do you write the proper condition statement for this? Note that 3rdparty1.js is on a separate domain, if that helps.
Thanks!
if (window.something3rdpartyprovided) { ... }.