Home

Awesome

badge-size <a href="https://vercel.com?utm_source=badge-size&utm_campaign=oss"><img align="right" src="https://www.datocms-assets.com/31049/1618983297-powered-by-vercel.svg" alt="Powered by Vercel" /></a>

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

BadgeURL
Normal size
Gzipped size
Brotli size
Custom label
PNG 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:

https://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|json]

Optional image format. By default svg is used.

When json is used, the response is a JSON object of the following shape:

{
  "color": "44cc11",
  "originalSize": 997,
  "prettySize": "997 B",
  "size": 997
}

[?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.<br> 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.<br> You can specify one of the following:

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

Optional size limits in bytes.<br> Max is a hard limit. Exceeding this will generate a red badge. <br> 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.<br> This setting will override the color option in the above two scenarios.

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

Contributors

<a href="https://github.com/ngryman"><img src="https://avatars.githubusercontent.com/u/892048?v=4" title="ngryman" width="80" height="80"></a> <a href="https://github.com/apps/dependabot"><img src="https://avatars.githubusercontent.com/in/29110?v=4" title="dependabot[bot]" width="80" height="80"></a> <a href="https://github.com/bfred-it"><img src="https://avatars.githubusercontent.com/u/53252526?v=4" title="bfred-it" width="80" height="80"></a> <a href="https://github.com/nathancahill"><img src="https://avatars.githubusercontent.com/u/1383872?v=4" title="nathancahill" width="80" height="80"></a> <a href="https://github.com/apps/greenkeeper"><img src="https://avatars.githubusercontent.com/in/505?v=4" title="greenkeeper[bot]" width="80" height="80"></a> <a href="https://github.com/FezVrasta"><img src="https://avatars.githubusercontent.com/u/5382443?v=4" title="FezVrasta" width="80" height="80"></a> <a href="https://github.com/OliverJAsh"><img src="https://avatars.githubusercontent.com/u/921609?v=4" title="OliverJAsh" width="80" height="80"></a> <a href="https://github.com/hairmot"><img src="https://avatars.githubusercontent.com/u/8102124?v=4" title="hairmot" width="80" height="80"></a> <a href="https://github.com/styfle"><img src="https://avatars.githubusercontent.com/u/229881?v=4" title="styfle" width="80" height="80"></a> <a href="https://github.com/XhmikosR"><img src="https://avatars.githubusercontent.com/u/349621?v=4" title="XhmikosR" width="80" height="80"></a>

<sup>Generated with contributors-faces.</sup>

Other projects

License

MIT © Nicolas Gryman