CO2.js library

Purpose:: Estimate carbon emissions
Website:: https://www.thegreenwebfoundation.org/co2-js/
Docs:: https://developers.thegreenwebfoundation.org/co2js/overview/
Source Code:: https://github.com/thegreenwebfoundation/co2.js
Known by:: Green Web Foundation & Fershad Irani

Description

CO2.js is a JavaScript library that allows developers to estimate the emissions associated with their apps, websites and software. At its core, CO2.js takes an input of data, in bytes, and returns an estimate of the carbon emissions produced to move that data over the internet. It can be run in Node.js server environments, in the browser, as well as on some serverless and edge compute runtimes.

Data source

Energy carbon intensity

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.

Data folder: https://github.com/thegreenwebfoundation/co2.js/tree/main/data

See also Energy Carbon Intensity.

Carbon estimation models

CO2.js: Methodologies for calculating website carbon

Sustainable Web Design model

Based on the system boundaries defined by SustainableWebDesign.org.

SustainableWebDesign.org-1680699165820.jpeg

It includes the energy used by the total system comprised of:

  1. the use-phase energy of datacentres serving content
  2. the use-phase energy network transferring the data
  3. the use-phase energy of user device an user is accessing content on
  4. the total embodied energy used to create all of the above

Emissions Calculation Formulas

Constant value of 0.81 kWh/GB is derived from raw data for the β€œExpected 2020 scenario” from the Andrae study. It tries to include the energy consumption of all system segments: consumer device use (52 %), network use (14 %), data center use (15 %) and hardware production (19 %).

The model also tries to account for caching:

  • 75% of requests are uncached - use the full figure for data transfer
  • 25% of requests ARE cached - use a much smaller figure here, and divide this figure by 50

Energy per visit in kWh

E = [Data Transfer per Visit (new visitors) in GB x 0.81 kWh/GB x 0.75] + [Data Transfer per Visit (returning visitors) in GB x 0.81 kWh/GB x 0.25 x 0.02]

Emissions per visit in grams CO2e

C = E x 442 g/kWh (or alternative/region-specific carbon factor)

Constants in source code: src/constants/index.js

OneByte model

Introduced by The Shift Project in their report on CO2 emissions from digital infrastructure, Lean ICT: for a sober digital.
This returns a number for the estimated CO2 emissions for the corresponding number of bytes sent over the wire, and has been used for video streaming, file downloads and websites.

Tutorials

CO2.js: An Open Library for Digital Carbon Reporting by Fershad Irani

Start calculating digital carbon emissions in 5 minutes with CO2.js - The Green Web Foundation

CO2.js: An Open Library for Digital Carbon Reporting - Branch by Fershad Irani

Examples on how to display the information

This page loaded in 0.71 seconds, produced just 0.009g of CO2, and is powered by renewable energy. Emissions are calculated using CO2.js and the Sustainable Web Design model.