I think it has to be an easy question but I have been searching around and have not found the answer anywhere.
The think is that I have an html page with some scripts (in the body) like this one:
<script type="text/javascript">grf();</script>
The grf() function is defined in an external .js file.
The question is: is this function executed once the browser has loaded the page AND all of its external js files? Or it can be the case that the function is executed before the .js files are loaded? And if so, how can I prevent this?
To see if a function is defined:
When an external script is found, the (x)html will not be read further untill the external script is read (and code inside executed if there’s any executable code there).
So, calling a function in an external file after the external file was ‘included’ cannot generate a function-not-defined error. (However, keep in mind that you WILL get errors if that external function tries to manipulate the DOM or elements that still “don’t exist” in the page.)