co2.js
A npm module for accessing the green web API, and estimating the carbon emissions from using digital services.
https://github.com/thegreenwebfoundation/co2.js
Category: Consumption
Sub Category: Computation and Communication
Keywords
carbon-estimates co2 co2-emissions hacktoberfest non-profit open-source sustainability
Keywords from Contributors
climate measure composer carbon watering climate-change transforms unitful animations snapshot
Last synced: about 18 hours ago
JSON representation
Repository metadata
An npm module for accessing the green web API, and estimating the carbon emissions from using digital services
- Host: GitHub
- URL: https://github.com/thegreenwebfoundation/co2.js
- Owner: thegreenwebfoundation
- License: other
- Created: 2020-02-23T19:39:37.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-04-18T08:55:36.000Z (9 days ago)
- Last Synced: 2025-04-25T12:09:58.873Z (2 days ago)
- Topics: carbon-estimates, co2, co2-emissions, hacktoberfest, non-profit, open-source, sustainability
- Language: JavaScript
- Homepage: https://developers.thegreenwebfoundation.org/
- Size: 7.89 MB
- Stars: 448
- Watchers: 15
- Forks: 58
- Open Issues: 28
- Releases: 41
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
README.md
CO2.js
One day, the internet will be powered by renewable energy. Until that day comes, there’ll be a CO2 cost that comes with every byte of data that’s uploaded or downloaded. By being able to calculate these emissions, developers can be empowered to create more efficient, lower carbon apps, websites, and software.
Documentation | Changelog | Roadmap
What is CO2.js?
CO2.js is a JavaScript library that enables developers a way to estimate the emissions related to use of their apps, websites, and software.
Why use it?
Being able to estimate the CO2 emissions associated with digital activities can be of benefit to both developers and users.
Internally, you may want to use this library to create a carbon budget for your site or app. It is also useful for inclusion in dashboards and monitoring tools.
For user facing applications, CO2.js could be used to check & block the uploading of carbon intensive files. Or, to present users with information about the carbon impact of their online activities (such as browsing a website).
The above are just a few examples of the many and varied ways CO2.js can be applied to provide carbon estimates for data transfer. If you’re using CO2.js in production we’d love to hear how! Contact us via our website.
Installation
Using NPM
You can install CO2.js as a dependency for your projects using NPM.
npm install @tgwf/co2
Using esm.sh
You can import the CO2.js library into projects using esm.sh.
import tgwf from "https://esm.sh/@tgwf/co2@latest";
Using a JS CDN
You can get the latest version of CO2.js using one of the content delivery networks below.
jsDelivr
You can find the package at https://www.jsdelivr.com/package/npm/@tgwf/co2.
- CommonJS compatible build
https://cdn.jsdelivr.net/npm/@tgwf/co2@latest/dist/cjs/index-node.min.js
- ES Modules compatible build
https://cdn.jsdelivr.net/npm/@tgwf/co2@latest/dist/esm/index.js
- IIFE compatible build
https://cdn.jsdelivr.net/npm/@tgwf/co2@latest/dist/iife/index.js
Unpkgd
You can find the package at https://unpkg.com/browse/@tgwf/co2@latest/.
- CommonJS compatible build
https://unpkg.com/@tgwf/co2@latest/dist/cjs/index-node.min.js
- ES Modules compatible build
https://unpkg.com/@tgwf/co2@latest/dist/esm/index.js
- IIFE compatible build
https://unpkg.com/@tgwf/co2@latest/dist/iife/index.js
Build it yourself
You can also build the CO2.js library from the source code. To do this:
-
Go to the CO2.js repository on GitHub.
-
Clone or fork the repository.
-
Navigate to the folder on your machine and run
npm run build
in your terminal. -
Once the build has finished running, you will find a
/dist
folder has been created. Inside you can find:dist/cjs
- A CommonJS compatible build.dist/esm
- An ES Modules compatible build.dist/iife
- An Immediately Invoked Function Expression (IIFE) version of the library.
TypeScript support
Type definitions for CO2.js are published in the DefinitelyTyped project, and are available on NPM at @types/tgwf__co2
.
If you want to use type definitions in your project, they should be installed as a devDependency.
npm install --dev @types/tgwf__co2
Marginal and average emissions intensity data
CO2.js includes yearly average grid intensity data from Ember, as well as marginal intensity data from the UNFCCC (United Nations Framework Convention on Climate Change). You can find the data in JSON and CommonJS Module format in the data/output
folder.
Using emissions intensity data
You can import annual, country-level marginal or average grid intensity data into your projects directly from CO2.js. For example, if we wanted to use the average grid intensity for Australia in our project, we could use the code below:
import { averageIntensity } from "@tgwf/co2";
const { data } = averageIntensity;
const { AUS } = data;
console.log({ AUS });
All countries are represented by their respective Alpha-3 ISO country code.
Publishing to NPM
We use np
to publish new versions of this library to NPM. To do this:
- First login to NPM by running the
npm login
command in your terminal. - Then run
npx np <VERSION>
. np
will run several automated steps to publish the new package to NPM.- If everything runs successfully, you can then add release notes to GitHub for the newly published package.
Release communication
CO2.js releases will be communicated through the following channels:
Channel | Minor Release (0.xx) | Patch Release (0.xx.x) |
---|---|---|
Github | ✅ | ✅ |
Green Web Foundation website | ✅ | ❌ |
W3C Slack Sustainability Channel | ✅ | ❌ |
ClimateAction.Tech Slack | ✅ | ❌ |
Green Web Foundation LinkedIn Account | ✅ | ❌ |
Licenses
The code for CO2.js is licensed Apache 2.0. (What does this mean?)
The average carbon intensity data from Ember is published under the Creative Commons ShareAlike Attribution Licence (CC BY-SA 4.0). (What does this mean?)
The marginal intensity data is published by the Green Web Foundation, under the Creative Commons ShareAlike Attribution Licence (CC BY-SA 4.0). (What does this mean?)
See LICENCE for more.
Contributors
To contribute changes back to this project, please follow the steps outlined in the CONTRIBUTING.md file in this repository.
Owner metadata
- Name: The Green Web Foundation
- Login: thegreenwebfoundation
- Email: [email protected]
- Kind: organization
- Description: The Green Web Foundation - Let's make the web green
- Website: https://www.thegreenwebfoundation.org
- Location: The Internet
- Twitter: greenwebfound
- Company:
- Icon url: https://avatars.githubusercontent.com/u/8995024?v=4
- Repositories: 69
- Last ynced at: 2024-10-30T03:50:10.533Z
- Profile URL: https://github.com/thegreenwebfoundation
GitHub Events
Total
- Create event: 15
- Release event: 6
- Issues event: 16
- Watch event: 47
- Delete event: 1
- Issue comment event: 30
- Push event: 39
- Pull request review event: 2
- Pull request review comment event: 2
- Pull request event: 29
- Fork event: 6
Last Year
- Create event: 15
- Release event: 6
- Issues event: 16
- Watch event: 47
- Delete event: 1
- Issue comment event: 30
- Push event: 39
- Pull request review event: 2
- Pull request review comment event: 2
- Pull request event: 29
- Fork event: 6
Committers metadata
Last synced: 4 days ago
Total Commits: 610
Total Committers: 27
Avg Commits per committer: 22.593
Development Distribution Score (DDS): 0.53
Commits in past year: 138
Committers in past year: 10
Avg Commits per committer in past year: 13.8
Development Distribution Score (DDS) in past year: 0.109
Name | Commits | |
---|---|---|
fershad | 2****d | 287 |
Chris Adams | c****s@p****k | 133 |
Fershad | i****h@f****m | 81 |
soulgalore | p****r@s****m | 25 |
drydenwilliams | h****o@d****k | 19 |
dependabot[bot] | 4****] | 15 |
Frazer Smith | f****v@o****m | 8 |
Brett Tackaberry | b****t@r****m | 7 |
Evan Hahn | me@e****m | 5 |
Malay Kumar | m****3@g****m | 4 |
Simon Fishel | s****f@g****m | 3 |
allcontributors[bot] | 4****] | 3 |
Ash Johns | m****l@a****m | 2 |
Matthew Griffin | m****n@s****m | 2 |
PrathumP | 1****P | 2 |
hamishfagg | i****b@i****t | 2 |
hanopcan | h****h@o****k | 2 |
Atul Varma | v****a@g****m | 1 |
Danielle Subject | D****t@i****m | 1 |
JamieB | j****e@g****k | 1 |
Pierre GERARD | p****d@c****m | 1 |
Piper | p****r@g****m | 1 |
Raymundo Vásquez Ruiz | r****r@p****m | 1 |
Thibaud Colas | t****s@g****m | 1 |
Jesper Fogh | f****f@g****m | 1 |
alexzurbonsen | a****n@t****m | 1 |
samuelIkoli | a****i@g****m | 1 |
Committer domains:
- tngtech.com: 1
- contentsquare.com: 1
- greengumption.co.uk: 1
- ibm.com: 1
- opcan.co.uk: 1
- ivdata.net: 1
- scottlogic.com: 1
- ashpjohns.com: 1
- evanhahn.com: 1
- rebel.com: 1
- drydenwilliams.co.uk: 1
- soulgalore.com: 1
- fershad.com: 1
- productscience.co.uk: 1
Issue and Pull Request metadata
Last synced: 4 days ago
Total issues: 101
Total pull requests: 168
Average time to close issues: 4 months
Average time to close pull requests: 29 days
Total issue authors: 30
Total pull request authors: 29
Average comments per issue: 3.8
Average comments per pull request: 1.29
Merged pull request: 135
Bot issues: 0
Bot pull requests: 52
Past year issues: 30
Past year pull requests: 35
Past year average time to close issues: about 1 month
Past year average time to close pull requests: 13 days
Past year issue authors: 10
Past year pull request authors: 11
Past year average comments per issue: 1.67
Past year average comments per pull request: 0.54
Past year merged pull request: 28
Past year bot issues: 0
Past year bot pull requests: 15
Top Issue Authors
- mrchrisadams (32)
- fershad (29)
- soulgalore (4)
- drydenwilliams (3)
- benjaminrancourt (2)
- michael-voit (2)
- hanopcan (2)
- alexzurbonsen (2)
- mgriffin-scottlogic (2)
- mgifford (2)
- thibaudcolas (2)
- wisefool (1)
- samuelIkoli (1)
- p-gerard (1)
- mishushakov (1)
Top Pull Request Authors
- fershad (34)
- mrchrisadams (27)
- dependabot[bot] (27)
- github-actions[bot] (23)
- soulgalore (15)
- Fdawgs (6)
- drydenwilliams (5)
- EvanHahn (3)
- sfishel18 (3)
- tackaberry (3)
- allcontributors[bot] (2)
- dsubject (2)
- hanopcan (2)
- raymundovr (1)
- SekhReddy (1)
Top Issue Labels
- roadmap (12)
- help wanted (9)
- good first issue (8)
- enhancement (8)
- designing (6)
- gwf-green-code-challenge (4)
- data (3)
- hacktoberfest (3)
- documentation (3)
- confirmed (2)
- funding-required (2)
- internal facing (1)
- release-planned (1)
Top Pull Request Labels
- dependencies (27)
- help wanted (1)
- javascript (1)
Package metadata
- Total packages: 2
-
Total downloads:
- npm: 33,897 last-month
- Total docker downloads: 36,880,715
- Total dependent packages: 6 (may contain duplicates)
- Total dependent repositories: 25 (may contain duplicates)
- Total versions: 68
- Total maintainers: 4
npmjs.org: @tgwf/co2
Work out the co2 of your digital services
- Homepage: https://github.com/thegreenwebfoundation/co2.js#readme
- Licenses: Apache-2.0
- Latest release: 0.16.7 (published 9 days ago)
- Last Synced: 2025-04-25T12:10:03.334Z (2 days ago)
- Versions: 61
- Dependent Packages: 6
- Dependent Repositories: 25
- Downloads: 33,864 Last month
- Docker Downloads: 36,880,715
-
Rankings:
- Docker downloads count: 0.22%
- Downloads: 1.118%
- Dependent repos count: 2.583%
- Average: 2.782%
- Stargazers count: 3.825%
- Dependent packages count: 4.389%
- Forks count: 4.557%
- Maintainers (3)
npmjs.org: @makakwastaken/co2
Work out the co2 of your digital services
- Homepage: https://github.com/thegreenwebfoundation/co2.js#readme
- Licenses: Apache-2.0
- Latest release: 0.12.4 (published over 1 year ago)
- Last Synced: 2025-04-25T12:10:05.802Z (2 days ago)
- Versions: 7
- Dependent Packages: 0
- Dependent Repositories: 0
- Downloads: 33 Last month
-
Rankings:
- Stargazers count: 3.879%
- Forks count: 4.61%
- Downloads: 10.391%
- Average: 12.934%
- Dependent repos count: 18.771%
- Dependent packages count: 27.017%
- Maintainers (1)
Dependencies
- 636 dependencies
- @tgwf/url2green ^0.4.0 development
- eslint ^8.15.0 development
- eslint-config-prettier ^8.5.0 development
- eslint-plugin-jest ^26.1.5 development
- eslint-plugin-prettier ^4.0.0 development
- jest ^28.1.0 development
- nock ^13.2.4 development
- np ^7.6.1 development
- pagexray ^4.4.2 development
- prettier ^2.6.2 development
- debug ^4.3.4
- actions/checkout v3 composite
- actions/setup-node v3 composite
- actions/checkout v3 composite
- peter-evans/create-pull-request v5 composite
Score: 26.885373877783575