Skip to content

Instantly share code, notes, and snippets.

@Nilpo
Created October 11, 2019 03:25
Show Gist options
  • Save Nilpo/295a0e7b91ca710e205a7f8c04ac115c to your computer and use it in GitHub Desktop.
Save Nilpo/295a0e7b91ca710e205a7f8c04ac115c to your computer and use it in GitHub Desktop.
Animating Favicons with jQuery
var favicon_images = [
'http://website.com/img/tmp-0.gif',
'http://website.com/img/tmp-1.gif',
'http://website.com/img/tmp-2.gif',
'http://website.com/img/tmp-3.gif',
'http://website.com/img/tmp-4.gif',
'http://website.com/img/tmp-5.gif',
'http://website.com/img/tmp-6.gif'
],
image_counter = 0; // To keep track of the current image
setInterval(function() {
$("link[rel='icon']").remove();
$("link[rel='shortcut icon']").remove();
$("head").append('<link rel="icon" href="' + favicon_images[image_counter] + '" type="image/gif">');
// If last image then goto first image
// Else go to next image
if(image_counter == favicon_images.length -1)
image_counter = 0;
else
image_counter++;
}, 200);
@JesusGod-Pope666-Info
Copy link

You need to break them up to images?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment