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

co2-shield

v1.0.2

Published

A tool to generate CO2 badges for websites

Downloads

117

Readme

PRs Welcome CO₂ Shield

CO₂ Shield Generator

Overview

The CO₂ Shield Generator lets you calculate the environmental impact of a webpage and display it in your GitHub project as a shields.io badge, powered by Beacon, which uses the OneByte model for calculating emissions created by The Shift Project.

Live Tool

You don't need to download or initialise anything to use this tool. Visit the live version here:

👉 CO₂ Shield Generator

Features

  • Badge Creation: Generates a badge using the Shields.io service.
  • Markdown Output: Provides a markdown snippet to embed the badge in project documentation.
  • Rating Details: Displays the CO₂ emissions per webpage view, along with a breakdown of ratings.

How to Use

  1. Input a URL: Type or paste the webpage URL you want to analyse. Ensure it's a valid web address.
  2. Submit the Form: Press 'Enter' or click 'Submit'. The generator fetches CO₂ data from Beacon.
  3. View Results: See the badge, the markdown snippet, and the detailed CO₂ emissions data.
  4. Copy Markdown: Use the 'Copy' button to copy the badge's markdown and embed it in your projects.
  5. Reset: Use the 'Reset' button to analyse another webpage.

Example

Here's an example of a badge and markdown generated by the tool for our website's homepage overbrowsing.com:

Preview

CO₂ Shield

Markdown

[![CO₂ Shield](https://img.shields.io/badge/CO₂-A+_0.041g-58C521)](https://https://overbrowsing.com/co2-shield/)

Rating System

The rating is based on the grams of CO₂e produced per webpage view for new visitors. Returning visitors have a lower footprint due to caching. The ratings are defined as follows:

| Rating | Color | CO₂e Emissions per View | | ------ | ---------------------------------------------------------- | ----------------------- | | A+ | A+ | Less than 0.095g | | A | A | Less than 0.185g | | B | B | Less than 0.34g | | C | C | Less than 0.49g | | D | D | Less than 0.65g | | E | E | Less than 0.85g | | F | F | Above 0.85g |

Dependencies

Installation

Install via NPM

To use CO2Shield in your project, you can install it via NPM:

npm install co2-shield

After installation, import and use the library in your project:

import CO2Shield from "co2-shield";

const co2Shield = new CO2Shield("app-container");
co2Shield.initialize();

Note: Ensure you are running your project with a bundler like Webpack, Vite, or Parcel that supports ES modules.


Install for Vanilla JS (Using a <script> Tag)

If you prefer not to use a package manager, you can include the library directly in your HTML using a CDN like UNPKG:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>CO2 Shield</title>
  </head>
  <body>
    <div id="app-container"></div>

    <!-- Include CO2Shield via UNPKG -->
    <script src="https://unpkg.com/co2-shield/dist/co2-shield.bundle.js"></script>

    <script>
      window.onload = () => {
        const co2Shield = new CO2Shield("app-container");
        co2Shield.initialize();
      };
    </script>
  </body>
</html>

Contributing

Contributions are welcome. Please feel free to submit an issue or a pull request.

License

CO₂ Shield Generator is released under the MIT license. Feel free to use and modify it as needed.