I want to do something very simple in javascript. I have a main.js file which needs to call a calculation method in math.js.
If I include in index.html these two files with script tag, first math.js and then main.js, am I garanteed that math.js will have finished loaded before I can use it in main.js ?
If not, would I need to do some overkilled hack like I read here How do I include a JavaScript file in another JavaScript file? or even worse because I can’t even see in that link how dependency is actually taken into account.
Update: Why can’t I do like what Dashcode seems to do How can I add my library to be loaded Dashcode parts ie just use document.write(‘…’)? Is in fact document.write robust enough on a very slow connection if the library was bigger than main.js ?
Set a variable in math.js and proove in main.js if this variable exist.
in main.js:
Edit:
Now you can start an wait function, until it is loaded: