[whatwg] scripts, defer, document.write and DOMContentLoaded

Ian Hickson ian at hixie.ch
Tue Jul 21 00:26:18 PDT 2009


On Tue, 21 Jul 2009, Boris Zbarsky wrote:
> 
> The thing is, your behavior also introduces issues as far as I can see 
> (e.g. requirements that network loads be performed while a script is 
> running without reentering the script, which means not firing any 
> progress events associated with those network loads, requirements about 
> execution of <script> with src pointing to javascript URIs, if those are 
> supported to start with, etc, etc).
> 
> It's not clear to me that what you're proposing is any simpler than what 
> Jonas is proposing.

I agree it's no simpler; I'm saying it's more compatible with IE.


> I'd be very interested in other implementor feedback here, but it seems 
> to me that the current proposal is much more complicated than simply 
> saying that document.write in a deferred script never blows away the 
> document...  Is that not sufficiently compatible for some reason?

I don't really understand what your proposal would actually translate to, 
in precise spec terms.

One alternative would be to make the scripts that have "src" attributes 
but are deferred be excluded from the innerHTML behaviour, and just have 
them do the old behaviour (which, in imprecise terms, is "blowing away the 
document", and in more precise terms, is to execute once the parser has 
passed the EOF point, with the insertion point undefined, such that 
document.write() implies a document.open()). This might work; I didn't see 
any of the bugs be regarding <script> elements with src="" attributes. But 
it's less compatible with IE than I usually try to be (I would have 
specced this innerHTML behaviour long ago if I'd thought to test for it).

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list