Skip to content

Release Guide: CO2.js v0.16

CO2.js v0.16 adds the Sustainable Web Design Model version 4 update to the library. This is the most significant update to the Sustainable Web Design Model in years, and allows developers to estimate digital emissions with a model based on updated peer-reviewed research. This version also introduces the Sustainable Web Design Ratings which developers can access in the results when using the Sustainable Web Design Model.

Sustainable Web Design Model version 4

The Sustainable Web Design Model (SWDM) is a widely adopted methodology for estimating digital emissions relating to websites. First released publicly in 2020, it SWDM version 3 was included in CO2.js from April 2022 (CO2.js v0.9). Since September 2022 (CO2.js v0.11) it has been the default carbon estimation model used by CO2.js.

In May 2024, version 4 of the Sustainable Web Design Model was published for initial community feedback. The update includes a change to the estimation formula, introduces separation between operational and embodied emissions, and updates the underlying data that forms the foundation of the model. We covered the changes made in the methodology design our recent post, Understanding the latest Sustainable Web Design Model update.

CO2.js v0.16 sees the inclusion of SWDM version 4 as one of the models that can be used in the library. Developers will be required to explicitly opt-in to using SWDM version 4, but besides this there should be no other code changes required when switching between models. The code sample below shows how to use SWDM version 4 in CO2.js to estimate 1000 bytes using the perByte function.

import {co2} from "@tgwf/co2";

const swdmV4 = new co2({model: "swd", version: 4});
const bytes = 1000;

const estimate = version4.perByte(1000);

We’ve updated our CO2.js Developer Documentation website to include a section specifically showing developers how they can use SWDM version 4 with CO2.js in their projects.

Read the docs.

Switching from Sustainable Web Design Model version 3 to version 4 in your projects

We know that some people use the Sustainable Web Design Model formula to estimate and track the carbon emissions of their websites over time. If you have an existing project that relies on the Sustainable Web Design Model version 3, and you would like to switch to version 4 then we strongly recommend that you recalculate previous estimates going back to at least 2022 if possible. We recommend that you re-estimate going back to at least 2022 as that is the year most of the key data sources for the SWDM version 4 methodology capture.

As SWDM version 4 is based on more recent data sources and research, estimated carbon emissions returned from the SWDM version 4 methodology on average two-thirds lower than comparable estimates performed using version 3. Therefore, in order for you to be better able to compare results over time, it is recommend that you re-baseline any previous estimates to use the SWDM version 4 methodology. We’ve explained more about the difference between the two version of the Sustainable Web Design Model in Understanding the latest Sustainable Web Design Model update.

Sustainable Web Design Ratings

The Sustainable Web Design rating system, which is similar to appliance energy efficiency rating grades. The rating system is a recent addition to the Sustainable Web Design guidance, and aims to provide a consistent way for regular users to understand the results of carbon emissions estimates for websites and digital services.

CO2.js v0.16 gives developers the option to return a corresponding Sustainable Web Design rating alongside emissions estimates. This should streamline the development process significantly as, until now, any user of CO2.js who wanted to adopt the rating system was required to code that themselves.

Ratings can be returned when using either version 3 or 4 of the Sustainable Web Design Model inside of CO2.js. The code snippet below shows how this can be done, and the corresponding results.

import { co2 } from '@tgwf/co2';

const emissionsAndRating= new co2({ model: 'swd', version: 3, rating: true });

emissionsAndRating.perByte(1000);

/* Returns:
{ total: 0.0003936519, rating: 'A+' }
*/

Publishing to JSR

We have also published version 0.16 of CO2.js to the new JSR package registry. You can find it at @greenweb/co2js.

Why publish to yet another package registry

The main reason for us publishing to JSR was to enable us to start taking advantage of some of the auto-generated documentation that it providers. This was a key objective we hoped to achieve as part of the Google Season of Docs (GSOD) project. As we played around with JSR, it became clear that we would not realise the full potential of JSR’s documentation capabilities without first converting the CO2.js codebase to TypeScript. Converting the library to TypeScript is not something we had the capacity to do as part of the GSOD project.

That said, with our current JavaScript plus JSDoc approach we were able to get some documentation generated and have published to JSR in order to expose that. Internally, we are exploring when and how we might be able to begin transitioning CO2.js to TypeScript or if there are other approaches that would allow us to utilise JSR’s documentation generation capabilities.


You can find details of every release for CO2.js on GitHub, where you’ll also be able find the changelog for this project.


Get notified about CO2.js news