[whatwg] Scripting Tweaks

Ian Hickson ian at hixie.ch
Fri May 18 21:56:56 PDT 2007


On Fri, 18 May 2007, Maciej Stachowiak wrote:
> > > 
> > > 1) Mozilla's DOMContentLoaded event is very handy. It fires when a 
> > > node's content has been loaded and parsed (the DOM has been 
> > > constructed). This is much better than the standard onload event as 
> > > it doesn't wait for binary content to also load.
> > 
> > Added.
> 
> FYI this was considered and rejected by the Web API Working Group at W3C 
> for inclusion in DOM Events, I believe because there did not seem to be 
> a truly valid use case (a popular use of this event is for late binding 
> of script, but given the event definition and the existence of 
> incremental rendering you can't actually be guaranteed the event will 
> fire before any content has rendered - XBL2 potentially provides a 
> better solution). I suggest referring to these discussions.

I was one of the people who said the use cases weren't convincing. :-)


> Also, <script defer> as defined in HTML5 gives you the exact same 
> capabilities as DOMContentLoaded: "If the defer attribute is present, 
> then the script is executed when the page has finished parsing." I'm not 
> sure it's necessary to add a second way to do the same thing, given that 
> the thing in question is somewhat suboptimal anyway.
> 
> That being said, I don't think it's a huge problem to add it, but you 
> may want to review the arguments raised in the Web API WG.

I did quite a lot of research before defining it. There's content 
depending on it. Two browsers support it, and workarounds are hacked into 
libraries to fake it for the two other browsers, including one that 
supports <script defer>. (The workaround is a <script defer>, but based on 
how people are using it it's not exactly what people are looking for.)

I agree it doesn't have strong use cases; XBL handles things like widgets 
better. But it's cheap, simple, interoperably implemented, and used. Seems 
like a no-brainer to me.

-- 
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