npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ryanrutkin/favicon.js

v0.0.8

Published

Favicon.js is a lightweight library that allows you to create an ICO formatted favicon from a canvas element.

Readme

Shoutout to the developer

This is a fork of the original favicon.js library published by John Sorrentino. John didn't create an npm package for this, so I forked it and created an NPM package.

Updates

  • I've converted this code to Typescript from the original Javascript. Though this library will not work in Node.js, I provided compilation through CJS as well as ESM.
  • The Favicon class can now be initialized with an image instead of just a canvas element.
  • Removed critical vulnerability by eliminating unnecessary dependency @swc/helpers
  • ICO files now maintain the original aspect ratio of the uploaded image (previously they were expected to be square).
  • ICO generation is currently broken, resulting in a solid black image.

Favicon.js

Favicon.js is a lightweight library that allows you to create ICO and PNG formatted favicons from a canvas element.

Examples

yarn install
yarn examples

Generate ICO

Generate an ICO file from a <canvas> element. Initialize a Favicon.Ico object with a canvas element. The canvas should be square for best results. Pass the generate method an array of sizes that the (layered) ICO file should contain.

const favicon = new FaviconJS(canvas);
const dataurl = favicon.ico([16, 32, 48]);

Generate PNG

Generate a PNG file from a canvas element. Initialize a Favicon.Png object with a canvas element. The canvas should be square for best results. Pass the generate method the size that should be generated.

const favicon = new FaviconJS(canvas);
const dataurl = favicon.png(32);

Generate Bundle

Generate multiple favicon format based on current best practices.

const favicon = new FaviconJS(canvas);
const package = favicon.bundle();

The bundle will contain the follow keys which map to common favicon formats.

  • ico - favicon.ico
  • png16 - favicon-16x16.png
  • png32 - favicon-32x32.png
  • png180 - apple-touch-icon.png
  • png192 - android-chrome-192x192.png
  • png512 - android-chrome-512x512.png

Example

The example below will generate an ICO formatted favicon that includes 3 sizes: 16x16, 32x32, and 48x48 pixels. The full example can be found here.

Preview

// Setup canvas
const canvas = document.getElementById("canvas");
canvas.width = 128;
canvas.height = 128;
const context = canvas.getContext("2d");

// Draw background
context.fillStyle = "#d85537";
context.fillRect(0, 0, canvas.width, canvas.height);

// Draw text
context.fillStyle = "#FFFFFF";
context.font = "100px Helvetica";
context.textBaseline = "middle";
context.textAlign = "center";
const x = canvas.width / 2;
const y = canvas.height / 2;
context.fillText("F", x, y);

// Create favicon.ico dataurl
const favicon = new FaviconJS(canvas);
const dataurl = favicon.ico([16, 32, 48]);

// Activate the download button
const download = document.getElementById("download");
download.href = dataurl;
download.setAttribute("download", "favicon.ico");