Functions - perVisit
Sustainable Web Design Model only

The perVisit() function can only be used with the Sustainable Web Design Models. This function includes assumptions the model authors have made about website visitors and caching as part its calculation. For that reason, we recommend only using it if you are comfortable with those assumptions. The perVisit() function is best used for calculating website carbon emissions.

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

const swd = new co2({ model: "swd" });

const emissions = swd.perVisit(1000000);

Here we are using the Sustainable Web Design Model, and using the perVisit() function to check the carbon emissions for transferring 1 million bytes.

Accepted parameters

The perVisit() function accepts the following parameters:

  • bytes number
    Required
    : The value of bytes to estimate emissions for.
  • green hosting boolean Optional: if the data being measured is served from a green web host.

Result

The perVisit() function returns a floating point decimal value which is the amount of CO2e (in grams) calculated using the function.