Say I have a script called makeFields.js which includes the method
function makeDateControls() {
document.write(/* ... */);
}
In my HTML, I link to that script in the head, like so:
<head>
<script type="text/javascript" src="makeFields.js"></script>
</head>
Then in my HTML, I have an inline script outside the head:
<div>
<script>
makeDateControls();
</script>
</div>
The question is: can I depend on the browser to wait for makeFields.js to finish downloading before it tries to call makeDateControls()? Does it matter whether I put the makeFields.js script tag in the head or in the body? Does the behavior depend on the presence of document.write()?
Although it seems like it wouldn't work, we haven't had any problems with this method as far as I can tell. Keep in mind however that I did not create this framework - I'm new on my team so change isn't easy.