The browser needs to wait on any <script> before it can render the rest of
the page, because the semantics of <script> have historically been
synchronous. <script>s need to be executed before later parts of the page
are rendered, or else you'll have unexpected bugs arising, because that's
not the way anyone has ever done it since <script> first existed.
Recent browsers are getting better at doing whatever they can in advance of
the actual script load -- fetching resources that they expect they'll need,
parsing, and so on. But I don't think any will actually render the rest of
the page before the script is done executing. What would happen if the
script did something like document.write("<!--")? Or if it redirected to
the different page? The user would have been shown something they were
never supposed to see according to the applicable standards.
This is one of the problems <script async> is meant to solve, incidentally,
but it won't really work for most ad scripts -- they tend to use
document.write() to output the ad. In principle you could use DOM methods
to insert the ad after the fact instead, of course. Then again, this would
mean the user could scroll right past the ad location without ever seeing
it . . .
I'm a web developer, though, and not a browser implementer, so take this
explanation with a grain of salt.
Posted Nov 27, 2009 1:03 UTC (Fri) by efexis (guest, #26355)
[Link]
On your past point about DOM insertion - you can reserve space on a page and then later fill it, for many <embed>'ed ads like those in flash, this is usually already the way.