[whatwg] DOMContentLoaded, load and current document readiness

On Tue, 31 May 2011, Henri Sivonen wrote:
>
> Recently, there was discussion about changing media element state in the 
> same task that fires the event about the state change so that scripts 
> that probe the state can make non-racy conclusions about whether a 
> certain event has fired already.
> 
> Currently, there seems to be no correct non-racy way to write code that 
> probes a document to determine if DOMContentLoaded or load has fired and 
> runs code immediately if the event of interest has fired or adds a 
> listener to wait for the event if the event hasn't fired.
> 
> Are there compat or other reasons why we couldn't or shouldn't make it 
> so that the same task that fires DOMContentLoaded changes the readyState 
> to "interactive" and the same task that fires load changes readyState to 
> "complete"?

Fixed for 'load'. I don't see a good way to fix this for 
'DOMContentLoaded', unfortunately. Note that 'readystatechange' events do 
fire synchronously with 'readyState' changes so you can always just use 
that instead of 'DOMContentLoaded' and 'load'. I haven't changed 
'pageshow', so you could still get code running between 'load' and 
'pageshow'. Let me know if you think we should merge those into one task 
as well.

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

Received on Monday, 9 January 2012 16:10:26 UTC