Skip to content

Instantly share code, notes, and snippets.

@dbader
Created December 8, 2014 16:57
Show Gist options
  • Save dbader/3f9adca03e655b90c2b8 to your computer and use it in GitHub Desktop.
Save dbader/3f9adca03e655b90c2b8 to your computer and use it in GitHub Desktop.
Dynamic favicons
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
canvas.width = 16;
canvas.height = 16;
ctx.fillStyle = '#F00'; // <- Pick a colour.
ctx.fillRect(0, 0, canvas.width, canvas.height);
var favicon = document.getElementsByTagName('link')[0];
favicon.href = canvas.toDataURL();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment