On Nov 15, 2007 12:31 PM, Michael Vincent van Rantwijk, MultiZilla
<[EMAIL PROTECTED]> wrote:
> Nickolay Ponomarev wrote:
> > On Nov 15, 2007 11:06 AM, Michael Vincent van Rantwijk, MultiZilla
> > <[EMAIL PROTECTED]> wrote:
> >>> //register Observer
> >>> window.addEventListener("load", MyObserver, false);
> >>> function MyObserver(){
> >>> var observerService = 
> >>> Components.classes["@mozilla.org/observer-service;1"]
> >>>         .getService(Components.interfaces.nsIObserverService);
> >> Don't do that here, but outside the observer; because it will 'run' for
> >> all loads!
> >>
> > Huh?
>
> This is two fold as moving "var observerService" out of the observer
> scope, makes the observer a few ms faster, and there is probably no need
> to add a new observer for each time the load event is triggered.
>
The listener added via window.addEventListener('load' ...) will not
run more than once, no? It handles the chrome window's load.

I saw some people checking that the listener doesn't do anything when
called a second time, but never got a reasonable explanation why that
was necessary. (It may have been necessary many years ago, but
extensions for modern versions of Firefox work fine relying on the
'load' listener firing only once.)

Nickolay
_______________________________________________
Project_owners mailing list
[email protected]
https://www.mozdev.org/mailman/listinfo/project_owners

Reply via email to