[whatwg] API to delay the document load event

Bjoern Hoehrmann derhoermi at gmx.net
Wed Apr 24 06:24:44 PDT 2013


* Robert O'Callahan wrote:
>1) User-agents provide thumbnails of Web pages (e.g. desktop Firefox,
>FirefoxOS and Safari do this). We want to avoid taking a thumbnail while
>the application is incompletely loaded. The firing of the document load
>event is not currently a reliable indicator since the application might
>have ongoing load activities (e.g. IndexedDB transactions, Websocket
>activity) that do not block the document load event.

My http://iecapt.sf.net/ and http://cutycapt.sf.net/ solve this simply
by waiting a user-configurable amount of time. SVG Tiny 1.2 also defines
a `snapshotTime` attribute to this end. It is not clear to me that some-
thing more flexible than simply waiting some time is a realistic option,
considering that if you actually want to snapshot something, you'll have
to do it even when the page hasn't said it's ready yet, otherwise you
may end up waiting forever.

>Proposal:
>Give Web applications APIs to explicitly delay the document load event. In
>particular, add a method "document.delayLoadEvent()" that causes the
>document load event to be delayed until a corresponding
>"document.stopDelayingLoadEvent()" method is called. Allow these to nest so
>that the document load event is delayed until at least as many calls to
>stopDelayingLoadEvent() have been made as there were calls to
>delayLoadEvent().

That seems entirely wrong to me, there may be all sorts of things hooked
to happen right after the load event, and you do not want to delay them
for some browser thumbnail feature. If web pages should have the ability
to say "I would like to inform you when the right time for snapshots has
come ... okay, now I'm ready", then there should be an explicit API for
that. Note in particular that it is rather hard to manage such a lock in
all cases correctly, so you better put in

  setTimeout(function(){
    for (var i = 0; i < 1000; ++i)
      document.stopDelayingLoadEvent();
  }, ...);

to avoid having this break your page.
-- 
Björn Höhrmann · mailto:bjoern at hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 



More information about the whatwg mailing list