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 🙏

© 2025 – Pkg Stats / Ryan Hefner

co2-compensator

v0.1.2

Published

Work out and offset the co2 of your digital services

Readme

Original Readme of CO2 JS Package of The Green Web Foundation

CO2

We know computers use electricity, and because most of the electricity we use comes from burning fossil fuels to generate, there is an environmental cost to every upload and download we make over the internet.

We cando something about this though. The same way we use performance budgets make apps and website faster and cheaper to run, we can use carbon budgets to make them faster, cheaper and greener.

The CO2 package from [The Green Web Foundation][tgwf] lets you quickly estimate these emissions, to make measurable improvements as part of your workflow.

It does this by implementing the 1byte model as used by the Shift Project, as introduced in their report on CO2 emissions from digital infrastructure, [Lean ICT: for a sober digital][soberDigital], to return a number for the estimated CO2 emissions for the corresponding number of bytes sent over the wire.

It is currently used in the web performance tool [sitespeed.io][], to help developers build greener, more planet friendly digital services.

If you want to build this kind of environmental information into your own software, and want some advice, we'd be happy to hear from you - please open an issue, remembering to link to your project.

This is open source software, with all the guarantees associated, so if you want professional advice, to a deadline, and you have a budget please see the services offered by the [Green Web Foundation][tgwf-services].

Installation

npm i -g co2-compensator

Usage

Comand Line (CLI)

co2-compensator <MB>  

Specify the MB to compensate.

Calculating emissions per byte

Server-side

This approach relies on the fs module and so can only be used on platforms, like node.js, that support this.


const CO2 = require('@tgwf/co2')
const bytesSent = (1024 * 1024 * 1024)
const co2Emission = new CO2();
estimatedCO2 = co2Emission.perByte(bytesSent)

console.log(`Sending a gigabyte, had a carbon footprint of ${estimatedCO2.toFixed(3)} grams of CO2`)

Browser-side

For browser-based solutions, you must import the co2.js submodule directly from node_modules. For example, like this:


const CO2 = require('node_modules/@tgwf/co2/src/co2.js')
const bytesSent = (1024 * 1024 * 1024)
const co2Emission = new CO2();
estimatedCO2 = co2Emission.perByte(bytesSent)

console.log(`Sending a gigabyte, had a carbon footprint of ${estimatedCO2.toFixed(3)} grams of CO2`)

Checking for green power

Because different digital services and websites use different forms of power, there is also a module for checking if a domain uses green power or not, and whether the domains linked to on a page use green power as well.


const greencheck = require('@tgwf/hosting')

// returns true if green, otherwise false
greencheck.check("google.com")

// returns an array of the green domains, in this case ["google.com"].
greencheck.check(["google.com", "kochindustries.com"])]

// returns an array of green domains, again in this case, ["google.com"]
greencheck.checkPage(["google.com"])

Notes

Please note, we currently look at just the carbon cost of generating the electricity, similar to how the IEA does, not the full life cycle cost of the energy.

Doing this would include things like:

  • the carbon emitted when carrying out activity associated with digging up the fuel
  • the carbon associated with mining the materials to build the power stations, datacentres, and so on
  • the end of life costs
  • the maintenance costs over the life of the datacentres, power generation and end user devices, and the rest of the internet

Life cycle figures do exist, but they are very difficult to do well. If you're interested in contributing to this. we'd love to hear from you.

Licenses

Apache 2.0