There are so many different ways to include JavaScript in a html page. I know about the following options:
The browser will execute the scripts in the order it finds them. If you call an external script, it will block the page until the script has been loaded and executed.
To test this fact:
// file: test.php
sleep(10);
die("alert('Done!');");
// HTML file:
Dynamically added scripts are executed as soon as they are appended to the document.
To test this fact:
Test
Order of alerts is "appended" -> "hello!" -> "final"
If in a script you attempt to access an element that hasn't been reached yet (example: ) then you will get an error.
Overall, yes you can include external scripts and then access their functions and variables, but only if you exit the current tag and start a new one.