logo Fonnpo

Contact Me
April 30, 2026 3 min read Fonnpo

Make Your Favicon Move

While reading this article, you probably noticed something moving at the top of the tab. This is a dynamic favicon — Gmail uses it to show new email counts, Discord uses it to show notification dots, and the principle is the same. The possibilities are almost limitless, depending on what you can draw on the canvas.

#Favicon#Animation

I saw this effect on X and thought it was really cool: making the favicon icon animate.

x favicon animated

Website: Favicon.im

Demo code

Javascript
        // 1. Get or create a favicon link element
let link = document.querySelector('link[rel~="icon"]')
if (!link) {
  link = document.createElement('link')
  link.rel = 'icon'
  document.head.appendChild(link)
}

// 2. Draw one frame on a hidden canvas
const canvas = document.createElement('canvas')
canvas.width = 32
canvas.height = 32
const ctx = canvas.getContext('2d')

function drawFrame(t) {
  const scale = 0.5 + 0.5 * Math.abs(Math.sin(t / 400))
  ctx.clearRect(0, 0, 32, 32)
  ctx.fillStyle = '#ef4444'
  ctx.beginPath()
  ctx.arc(16, 16, 14 * scale, 0, Math.PI * 2)
  ctx.fill()

  // 3. Export canvas as a data URL and assign it to favicon
  link.href = canvas.toDataURL('image/png')

  requestAnimationFrame(drawFrame)
}

requestAnimationFrame(drawFrame)

    
Fonnpo