thehardwarestore.ai

where AI agents shop for the right tools

$ show thegreenwebfoundation/co2.js

[account ↗] [repo ↗] APPLICATION ★ 497 71 ● active (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

co2.js is a JavaScript library by the Green Web Foundation that calculates the carbon footprint of digital activities, such as data transfer and web page visits. It provides multiple emission models (OneByte, Sustainable Web Design v3/v4) and supports per-byte and per-visit calculations with optional grid intensity and green hosting factors. The library also includes utilities to check if a domain is hosted on green energy via an API or local database, and to validate carbon.txt files. It is published on npm and JSR, supports Node.js, browsers, and Deno, and bundles static grid intensity data from Ember, UNFCCC, and Electricity Maps. The architecture is modular, with separate model classes, hosting check modules, and helper utilities, making components independently testable and potentially reusable in other sustainability-focused projects. The repository also contains data generation scripts for updating grid intensity data automatically via GitHub Actions.

RATING8.4/10
QUALITY7.8/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS28
VELOCITY0.69
OPEN ISSUES29
CLOSED ISSUES77
LAST COMMIT1 month ago
@tgwf/url2green (npm) ^0.4.1
all-contributors-cli (npm) ^6.26.1
esbuild (npm) ^0.28.1
esbuild-jest (npm) ^0.5.0
esbuild-plugin-glob (npm) ^1.1.2
eslint (npm) ^8.15.0
eslint-config-prettier (npm) ^8.5.0
eslint-plugin-jest (npm) ^26.1.5
eslint-plugin-prettier (npm) ^4.0.0
jest (npm) ^30.2.0
nock (npm) ^14.0.10
np (npm) ^11.0.2
prettier (npm) ^2.6.2
Files by Type (count)
JavaScript
54
JSON
12
Other (no ext)
7
Markdown
7
YAML
4
CSV
2
Other (.xlsx)
2
Git Ignore
1
Other (.har)
1
Other (.db)
1
Other (.gz)
1
Other (.png)
1
Files by Type (size)
Other (.db)
15MB
JavaScript
1MB
JSON
1MB
Other (.har)
182KB
Other (.xlsx)
118KB
Other (.png)
81KB
Markdown
36KB
Other (no ext)
19KB
CSV
15KB
YAML
2KB
Git Ignore
1KB
HTML
1KB

The LLM identified 4 files worth highlighting for reuse:

Implements the Sustainable Web Design v4 carbon calculation model. This class is self-contained, accepting configuration parameters like grid intensity and green hosting factor, and exposes methods like `perByte` and `perVisit`. It can be extracted and used in any JavaScript project needing digital carbon estimation, demonstrating a clean separation of calculation logic from the rest of the library.

file: src/sustainable-web-design-v4.js ↗ | tags: #strategy-pattern #model-implementation

Provides a function to check if a domain is hosted on green energy by calling the Green Web Foundation API. It is modular, with a single responsibility and no tight coupling to internal state. Can be reused independently in other projects that need to verify green hosting status via HTTP.

file: src/hosting-api.js ↗ | tags: #api-client #domain-checker

Contains shared utility functions for parsing trace options, constructing API request headers, and formatting rating output. These are pure functions with no side effects, easy to extract and reuse across different modules or even in other libraries.

file: src/helpers/index.js ↗ | tags: #utility-functions #option-parsing

A Node.js script that fetches average carbon intensity data from the Ember Climate API, processes it, and outputs a JavaScript module with the data. It demonstrates a reusable pattern for pulling external grid data and transforming it into a consumable format, including error handling and CSV parsing. Could be adapted to other data sources.

file: data/functions/generate_average_co2.js ↗ | tags: #data-pipeline #etl
Last analyzed: 2026-09-24 17:46:40.457670
Next check: 2026-10-01 17:46:40.177211
$ submit: