There are a few different models that can be used to measure digital carbon emissions. CO2.js includes two of these - the OneByte model, and the Sustainable Web Design model. This guide will show you how use the different carbon estimation models available in CO2.js.
This guide will not go into the details of each model. If you'd like to learn more about the OneByte or Sustainable Web Design models then take a look at Methodologies for calculating website carbon.
CO2.js uses the OneByte model by default. So once you have loaded the CO2.js library into you'll be ready to use this model.
import { co2 } from '@tgwf/co2'
const oneByte = new co2()
If you want to use the Sustainable Web Design model, then you'll need to let CO2.js know. This can be done by passing in a model
parameter with a value of "swd"
when you initiate a new co2()
object.
import { co2 } from '@tgwf/co2'
const swd = new co2({ model: "swd" })