jquery img.load() test

Will jquery fire the .load() event for every img on the page, even cached images and img tags sharing the same image?

by b9chris

HTML

<div id=status></div>
<img id=img1 /><br/>
<img id=img2 />

JavaScript

var img1 = $('#img1');
var img2 = $('#img2');

var status = $('#status');
var h = [];
function loaded(tag, s) {
    tag.unbind();
    tag.load(function() {
        h.push(s);
        status.html(h.join('<br/>'));
    });
};

// Test basic image loading
loaded(img1, 'img1 loaded.');
loaded(img2, 'img2 loaded.');
img1[0].src = '//brass9.com/ui/ball.png';

// Test same image, 2 img tags
img2[0].src = '//brass9.com/ui/ball.png';

setTimeout(function() {
    // Rotate out the image, then rotate it back in
    loaded(img1, 'img1 google loaded.');
    img1[0].src = '//www.google.com/images/srpr/logo3w.png';
}, 1000);

setTimeout(function() {
    loaded(img1, 'img1 repeat loaded.');
    img1[0].src = '//brass9.com/ui/ball.png';
}, 2000);

setTimeout(function() {
    loaded(img1, 'img1 consecutive repeat loaded.');
    img1[0].src = '//brass9.com/ui/ball.png';
}, 3000);