show loading gif of image only if it is really loading it for the first time
- by Y.G.J
i have 2 img elements. 2 id's for them: rimg and limg.
limg is the loading gif and rimg is the reloaded full vertsion of the image.
the is the code to show the loading before image finish to load:
$("#limg").fadeIn("fast");
$("#rimg").attr("src",$(that).attr("bsrc")).load(function(){
$("#limg").fadeOut("fast",function () {
$("#rimg").attr("alt",$(that).attr("alt"));
$("#rimg").fadeIn("normal");
});
});
if i log into the site for the first time, it shows me the loading gif.
if it is not my first time it is still showing that but i need the loading to be smooth without that loading
how can i check if the image is loaded and cached before showing the loading gif?