I'm using this code to load gif after other content, play css keyframe animation after gif loaded and reset gif at css animation start.
$(window).load(function() {
var img = document.createElement("img");
imageUrl = "deszcz_dl.gif?"+ new Date().getTime();
img.src = imageUrl;
var doneTheStuff;
var func=function(){
if (!doneTheStuff) {
doneTheStuff = true;
console.log("hi");
img.src = " ";
img.src = imageUrl;
}
$("body").removeClass("preload");
$("#layer1").removeClass("loading");
}
$('#layer1').html("<img class='deszczimg' src="+ img.src + " alt=''>");
if(img.complete){
func.call(img);
}
else{
img.onload=func;
}
});
But its not working in IE 11 - gif isn't restarting... i don't know why. Working well in chrome and ff.