From: Matt Kruse on
There is a discussion going on in the jquery-dev mailing list that
piqued my curiosity. I'm interested to know if the smart people here
have a good answer.

Is there a cross-browser way, in script, to determine if window.onload
has already fired?

If a script is lazy loaded and needs the DOM to be ready, it can
attach to the window's load event. But if that has already fired, then
the script's code will never run. Alternatively, it can just fire its
code inline, but the DOM may not be ready.

Thoughts?

Matt Kruse
From: Thomas 'PointedEars' Lahn on
Matt Kruse wrote:

> There is a discussion going on in the jquery-dev mailing list that
> piqued my curiosity. I'm interested to know if the smart people here
> have a good answer.
>
> Is there a cross-browser way, in script, to determine if window.onload
> has already fired?
>
> If a script is lazy loaded and needs the DOM to be ready, it can
> attach to the window's load event.

But it should not. The loading state of the window has nothing to do with
the loading state of the document. We've been over this.

> But if that has already fired, then the script's code will never run.
> Alternatively, it can just fire its code inline, but the DOM may not be
> ready.
>
> Thoughts?

Smart people use the standards-compliant `onload' attribute instead.


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(a)news.demon.co.uk>
From: Matt Kruse on
On Nov 19, 12:30 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
wrote:
> But it should not.  The loading state of the window has nothing to do with
> the loading state of the document.  We've been over this.

Fine then, substitute in any other method you prefer.

> Smart people use the standards-compliant `onload' attribute instead.

Could you be more specific?

Matt Kruse

From: Thomas 'PointedEars' Lahn on
Matt Kruse wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Smart people use the standards-compliant `onload' attribute instead.
>
> Could you be more specific?

<body onload="...">


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
From: Matt Kruse on
On Nov 19, 1:06 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
wrote:
>   <body onload="...">

Script cannot add itself to this attribute, though.

You're steering away from the real question, anyway. Regardless of
whether you feel it should be used, is there any cross-browser way to
detect if window.onload has already fired?

Matt Kruse