 <p>The problem is that the browser is downloading the image when you first reference it, and not before.</p> <p>I'd simply have two image elements and hide/show them instead of changing the <code>src</code> attribute of a single element.</p>