On Sep 18, 2012, at 5:47 PM, Jon Robson <jdlrobson(a)gmail.com> wrote:
Awesome!
Correct me if I'm wrong but the way this is currently written an image for
foo.jpg will first load foo.jpg then replace the src attribute for this
element then load the image foo-2.0.jpg ?
It did that because the javascript function was hooked on window.load, which by
design does not fire until all images are downloaded.
The patch [1] has been revised and now fires on document ready, which should be
early enough to not waste much bandwidth.
I suggest we built-upon or write or own module further and integrate the
"lazy-load" principle. In other words, on document ready fix the images above
the fold, which may or may not have started downloading yet.
Then cancel the rest and set those appropriately just before they come into
view. That saves bandwidth in general (by not loading images when they are not
visible), and makes sure to download the right image based on the environment at
that point in time.
When a standard for srcset (or whatever it will be called) is ready and actually
implemented in some browser we could also opt to keep it without javascript.
Assuming plans won't get worse, the standard will include a natural fallback by
storing the 1-0 ratio image in the src attribute. Which is what we'd want on
older browsers/devices anyway.
-- Krinkle