If one.js happens to finish loading before two.js even gets parsed, will x exist? Surely this is possible because once an asynchronous script has been loaded, it's immediately executed and blocks further parsing of the HTML file. Thereby blocking two.js before it defines x.
To my knowledge, JavaScript doesn't need to resolve variables within a function. Instead, it waits until the function is executed to determine it's existence. Since x.prt isn't used until the window and it's resources (including two.js) have loaded, it should be safe load both scripts asynchronously, right?
jsfiles.html:
...
<script src="lib/one.js" type="text/javascript" async="async"></script>
<script src="lib/two.js" type="text/javascript" async="async"></script>
...
one.js:
window.addEventListener("load", function() {
x.prt("Will this print 100% of the time?");
}, false);
two.js
var x = {
prt: function(str) {
console.log(str + " Or will this definition not be seen?");
}
};