[whatwg] events when navigating away before page load?

Ian Hickson ian at hixie.ch
Fri Dec 14 12:10:44 PST 2012


On Fri, 14 Dec 2012, Mike Wilson wrote:
> 
> Anyway, the finding that originally got me started on looking at this 
> was that I received an unload event without a preceeding load event. 
> Naively this seems logically wrong, but I appreciate these are 
> complicated matters so I'm content with the answer that this probably 
> shouldn't be expected in these kinds of cases.

Yeah, this whole area is rather gnarly.

As a general rule, the intent of the spec is that you get a "load" when 
all your scripts (and other resources) have loaded, and you get an 
"unload" when the page is going away. Thus if the page goes away before 
the page has finished loading, you just get an "unload".

We additionally also suggest firing a "load" and so forth when the user 
aborts the page, on the assumption that you probably have all the scripts 
you need and are only missing minor things like ads or analytics, but that 
doesn't apply when the page is aborted because another page is going to 
replace 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