[whatwg] Detached elements and delaying the load event

Ian Hickson ian at hixie.ch
Wed Jan 25 15:06:37 PST 2012

On Tue, 6 Sep 2011, Andrew Oakley wrote:
> I'm going to use the <img> element as an example here, but the same 
> thing applies to other elements such as <iframe>, <video>, <audio>.
> I'm going to assume that the user agent "obtains the images 
> immediately", given that seems to be what most browsers do.
> If an img element is created and given a src attribute (but not 
> necessarily attached to the tree) then, according to HTML5, we need to 
> "update the image data" and therefore delay the load event.  I guess 
> this means we should lock the image element in a similar fashion to 
> XMLHttpRequest objects, otherwise the image could be garbage collected 
> before it has been loaded and therefore block the load event 
> indefinitely.
> Firefox, Opera, Chrome and Safari do seem to implement this behaviour, 
> IE does not.
> I would prefer not to implement this and just say "detached elements do 
> not delay the load event", but I'm not sure if that will always work.
> Can we please get a clarification in HTML5, either to say that these 
> detached objects must not be garbage collected while they are delaying 
> the load event, or to say that they do not delay the load event.

Done for <img>.

<video> and <audio> already had requirements to this effect.

<iframe> outside a document doesn't initiate a load, so it's case is 

Let me know if I missed anything.

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