Skip to content

Latest commit

 

History

History
9 lines (5 loc) · 915 Bytes

File metadata and controls

9 lines (5 loc) · 915 Bytes

A repository for some random Javascript/Coffeescript code that others might find useful.

Cancelable Image Loader (uses jQuery 1.5 - might work with earlier versions)

I needed a way to be able to cancel html5 image loads. When replacing the the src attribute on an image, most browsers don't cancel a previous loading image. This code, creates an iframe to load the image and can stop it by issueing a window.stop() in that iframe to cancel the image load.

To test it, fire up fiddler2, set it to simulate modem speeds and then using this sample jsfiddle repeatedly click on "Load Next" quickly and watch the fiddler2 window to make sure the requests are being canceled.

The code is writen in coffee script, but a compiled javascript version is available here if you need it.