Oct 15, 2019
White Arrow icon
Back to all Elements

Animated Favicon

A short code that changes multiple .png files to create animation.

Before starting this little project, you'll need these 2 things:

  • png/jpg sequence of your animation.
  • A place to store the animation sequence files (eg. AWS S3 repository).

Let's get to it:

1. Rename all your sequence files to numbers 0 - 10 (or as high as you need)

  • 0.png
  • 1.png
  • 2.png
  • etc'...

2. Upload all the files to the same folder. Copy+Paste to a note the folder path and the 1st file path.

3. Go to your Custom Code tab in the project settings.

In the end of the <head> tag section add the <link id="favicon...> line. Edit the href link to your 1st file path (see in the code section below).

4. In the before </body> tag section paste the rest of the code (from <script> to the </script> including)

Edit the 'http://your-folder-path' to your sequence folder path (keep the apostrophes)

5. Change the 'faviconIndex %' (in my code 7) to the number of sequence files you have)

6. And last thing - change the timing between each file. In my code it's 3000 (3 sec.)

<link id="favicon" rel="shortcut icon" href="http://1st-file-path/fav-seq0.png" type="image/x-icon">

<script>

window.onload = function() {

 var faviconIndex = 0;

 var favicon = document.getElementById('favicon');

 setInterval(function() {

         favicon.href = 'http://your-folder-path/' + faviconIndex + ".png";

         faviconIndex++;

         faviconIndex %= 7;

   }, 3000);

};

</script>

Copy

Preview:

Share:

Whenever possible, use Class Names to target the elements in your interaction. You never know when you'll need to duplicate and use it somewhere else...

Might also interest you:

Webflow Dashboard Workspaces Hack

Webflow UI Hack
Code
CSS

Convert the Workspaces dropdown to an open sidebar with custom order.

Read more
White Arrow icon

Dynamic Height

Code
Tricks
JavaScript

A (custom code) solution that combines CSS variables and Vanilla JavaScript for the shrinking / growing of browser top & bottom bars.

Read more
White Arrow icon

Desktop Grid, Mobile Slider

Cloneable
Tricks
Layout

Change Webflow's Slider to act as a "regular" grid block on desktop, but go back to Slider on Tablet and smaller screens.

Read more
White Arrow icon