To find out if a function is defined:
// functions are defined or undefined just like regular variables function myFunc() { /*--code here--*/ } // So we just need to see if it defined if( myFunc ) { /*--do something here--*/ } else { /*--wait, retry or w/e--*/ }
When an external script is detected, (x) html will not be considered further until the external script is read (and the code inside is executed if there is executable code).
Thus, a function call in an external file after the external file has been "included" cannot generate an error not defined by the function. (However, keep in mind that you will get errors if this external function tries to manipulate the DOM or elements that still "do not exist" on the page.)
cuisdy
source share