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 🙏

© 2024 – Pkg Stats / Ryan Hefner

badge-size

v1.0.0

Published

Displays the size of a given file in your repository

Downloads

22

Readme

badge-size npm travis

Displays the size of a given file in your repository.

badge-size allows you to display in real time the size of a given file which lives in your repository. The size is always the one of your last pushed commit.

It is mainly designed for front-end library authors that want to advertise the weight of their builds to their users. But you can use it for any other purpose of course :v:.

Examples

Badge | URL :------------|:---------------------------------------------------------------------------------| Normal size | Gzipped size | Brotli size | Custom label | PNG format | JPG format |

Usage

It works like any other badge service you may know and it's configurable in the image url itself. Here is the general pattern of a typical badge-size url:

http://img.badgesize.io/:filepath[.svg|png|jpg][?compression=gzip|brotli][&label=string][&max=string][&softmax=string]

:filepath

Relative URL of file on GitHub of any absolute URL if hosted elsewhere.

The format of the GitHub URL is the same as when you browse it in the source explorer, minus blob/ part. Here is its typical form:

:user/:repo/:branch/:path

For example if I want to point to this repository index.js, it would be:

https://github.com/ngryman/badge-size/master/index.js

Note that the branch name is mandatory.

[.svg|png|jpg]

Optional image format. By default svg is used.

[?compression=gzip|brotli]

Optional compression format to measure. It's useful if you want to advertise the true size your file would take on the wire, assuming the server has gzip or brotli compression enabled.

[&label=string]

Optional text to display in the badge instead of size / gzip size / brotli size.

[&color=string]

Optional background color. By default it's brightgreen. You can specify hexadecimal colors, without the dash (i.e bada55) or one of the following named colors:

[&style=string]

Optional style. By default it's flat. You can specify one of the following:

[&max=string] [&softmax=string]

Optional size limits in bytes. Max is a hard limit. Exceeding this will generate a red badge. If softlimit is provided (in addition to max) and the file size falls within the range of max and softmax, a yellow badge will be generated. This setting will override the color option in the above two scenarios.

http://img.badgesize.io/:filepath?max=100000&softmax=200000

Contributors

Generated with contributors-faces.

License

MIT © Nicolas Gryman