[whatwg] API to delay the document load event

James Graham jgraham at opera.com
Mon Apr 29 03:50:34 PDT 2013


On 04/29/2013 11:42 AM, Robert O'Callahan wrote:
> On Mon, Apr 29, 2013 at 8:56 PM, James Graham <jgraham at opera.com
> <mailto:jgraham at opera.com>> wrote:
>
>     On 04/29/2013 05:26 AM, Robert O'Callahan wrote:
>
>         Also, this is a feature where it's trivial for applications to
>         gracefully
>         degrade on browsers that don't have the feature.
>
>
>     I'm not sure that's true. I mean, it's *possible* but you have to be
>     careful to never depend on anything that could happen after the
>     "natural" load event in e.g. your load event handler. I can quite
>     easily see people getting that wrong.
>
>
> I'm not sure what you're getting at here.

I mean, let's say you delay the load event until after some data has 
loaded over a web socket. If you try to use that data from the load 
event handler it can fail in a racy way in UAs that don't support 
delaying the load event. This also seems like the kind of race that you 
are more likely to win on a local network, so it wouldn't necessarily be 
caught during development.

>     In general this seems quite a scary design. The load event is rather
>     intimately tied in to the lifecycle of the document, and encouraging
>     people to arbitrarily delay it feels like a potential source of bugs
>     and confusion.
>
>
> Adding new things that delay the load event has not been a source of
> bugs and confusion in my experience. Authors do it a lot and we've done
> it in specs too.

So far we have kept the model where the load event is auomatically 
managed by the UA, rather than giving the developer direct control of it.

>     Is getting screenshots of pages for thumbnails really something that
>     needs an author-facing API? In general the concept of "fully loaded"
>     doesn't make any sense for a class of modern web applications, which
>     might keep loading content or changing their presentation across
>     their liefetime. Therefore it seems like simply taking one
>     screenshot at page load and replacing it with one a little later
>     after a timeout might be a good-enough solution.
>
>
> The problem is when you next load the application. You don't want to
> replace a good screenshot with a screenshot of the application saying
> "Loading...".

Then don't replace the screenshot with one taken at the load-event time 
if you already have one.



More information about the whatwg mailing list