I’m wondering, where the script interpretation starts in a document with an iframe, that contains another document, with "<header><script>" or possibly "<body><script>". I just really need to ensure that the execution happens in the “outer” document before the iframe document, but it seems that it is random, is that right ?
BTW, what about the order of interpretation of referenced javascripts ? Does it depend on “where” in the document I reference it ?
To do this with 100% certainty, you would have to create the iframe in the outer document’s
DOMReadyevent (e.g. with jQuery’s.ready()). If you embed it directly into the document, there is indeed no guarantee of when the scripts will execute.Yes, script blocks get executed in the order they are in the page. Here is a great answer on the issue: Load and execution sequence of a web page?