[whatwg] API to delay the document load event

Glenn Maynard glenn at zewt.org
Sun Apr 28 14:08:53 PDT 2013


On Sun, Apr 28, 2013 at 1:00 PM, David Bruant <bruant.d at gmail.com> wrote:

> Each widget needs some way to express that it's ready, but doesn't
> necessarily need to express it to the document directly. A "widget manager"
> can load the widgets, gather all widgets "ready" events and trigger the UA
> "AppReady" event when the widgets are ready.
>

You shouldn't have to roll your own API to do this, because then you end up
only being able to use code that uses the same solution as everything else
(or gives a hook, which is a needless complication).  Give everyone a
consistent solution to begin with, and you avoid that problem.

I don't think we should be promoted patterns where widget are fully
> independent which is pretty much the equivalent of a script injection
> (where anything can happen, like one forgetting to call its
> delay.finished()).
>

I think you're confusing widgets (more generally, code libraries) with
sourcing code from untrusted sites.  Obviously nobody should do that, but
it has nothing to do with this.

I believe one event to trigger will be hard enough in complex applications,
> let's not allow more opportunities to mess it up by distributing to
> independent actors the authority to trigger one event to the UA.
>

With the approach I suggested, the users of the API would not be able to
trigger the event.  They would only be able to delay it.

JS implementation: https://zewt.org/~glenn/finished-loading.html

On Sun, Apr 28, 2013 at 1:21 PM, David Bruant <bruant.d at gmail.com> wrote:

>  In the Firefox bug, roc suggested [1]:
> "let the app specify <html loading>, and remove the attribute when done.
> (...) use a mutation listener to detect its removal."
> This is delightful; my new favorite idea on the topic. We don't need
> anything more.
>

As soon as two bits of code try to use this, each unaware of the other,
chaos will ensue as they stomp on the attribute set by the other.  This is
more or less a global variable.

-- 
Glenn Maynard



More information about the whatwg mailing list