Skip to content

Dynamic favicon library via data uris (canvas.toDataURL() etc)

Notifications You must be signed in to change notification settings

component/favicon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Favicon

Dynamically change a favicon using a data uri string, typically from canvas.toDataURL().

Installation

$ component install component/favicon

Example

Count from 0 through 9:

var icon = require('favicon');
var canvas = document.createElement('canvas');
canvas.width = canvas.height = 16;
var ctx = canvas.getContext('2d');
ctx.font = '16px Helvetica, Arial, sans-serif';

var nums = [0,1,2,3,4,5,6,7,8,9];
var i = 0;

setInterval(function(){
  ctx.clearRect(0, 0, 16, 16);
  var n = nums[i++ % 10];
  ctx.fillText(n, 0, 15);
  icon(canvas.toDataURL());
}, 300);

API

icon(string)

Set the favicon to the given data uri string.

icon.reset()

Reset to the original favicon.

License

MIT

About

Dynamic favicon library via data uris (canvas.toDataURL() etc)

Resources

Stars

Watchers

Forks

Packages

No packages published