[whatwg] script postonload

Anne van Kesteren annevk at opera.com
Wed Feb 10 00:57:10 PST 2010

On Mon, 08 Feb 2010 23:06:07 +0100, Steve Souders <steve at souders.org>  
> I'd like to propose the addition of a POSTONLOAD attribute to the SCRIPT  
> tag.
> The behavior would be similar to DEFER, but instead of delaying  
> downloads until after parsing they would be delayed until after the  
> window's load event. Similar to DEFER, this new attribute would ensure  
> scripts were executed in the order they appear in the document, although  
> it could be combined with ASYNC to have them execute as soon as the  
> response is received.
> Developers can do this now using JavaScript, but it's complex and  
> errorprone. For example, how should the script be added to the document?  
> People typically append to the 'head' element, but some pages don't have  
> a 'head' element and some browsers don't create a default one. And  
> 'documentElement' doesn't work in all browsers either. The safest path  
> I've seen is to append to ( head || body ). Whether everyone agrees this  
> is best, it reveals the complexity developers will have to consider.
> Adding this attribute would lower the bar promoting this best practice  
> for making web pages faster.

Which browsers do not create a <head> element? I thought we fixed our bug.  
Also, introducing new features mainly to work around existing bugs is  
generally not a good idea. We'd only increase the potential for  
interoperability issues.

Anne van Kesteren

More information about the whatwg mailing list