[whatwg] ProgressEvents for Images

On 2/23/12 7:38 PM, Hans Muller wrote:
>    Hans - It's useful if you want your listener to run after all of the
> load listeners have run, and code that you haven't written adds its own
> load listeners.

I strongly urge you to read 

Or put another way, what will you do a year after this is standardized, 
when the code that you haven't written is adding loadend listeners?

> The problem with using setTimeout() to schedule a listener to run after
> all of image's load listeners has run is that you've got to guess how long
> loading the image (or failing to load the image) and running its listeners
> will take.

No, you don't.  You simply do:

   function delayedLoadStuff() {
     setTimeout(doTheThingIWant, 0);
   img.addEventListener("load", delayedLoadStuff, false);
   img.addEventListener("error", delayedLoadStuff, false);

> If applications where multiple image load listeners are added by different
> modules really are a rarity (I wouldn't know) then I'll be happy to
> concede that loadend isn't needed.

And they are aren't, then it doesn't help, except in the very short term 
until those modules start using loadend themselves....


Received on Thursday, 23 February 2012 17:23:18 UTC