Green-Software-Foundation/if-unofficial-plugins

Allow variable adjustment when using SWD model in CO2.js

fershad opened this issue ยท 5 comments

Currently, the CO2.js implementation takes bytes and green-web-host as inputs. As a result, the calculation will use the global average grid intensity for all system segments.

The implementation of the Sustainable Web Design (SWD) model in CO2.js allows for an additional options object to be passed. Inside of this object, a user can specify the grid intensity to be used in calculations for individual segments. They can do this by entering a number value, or specifying a country using the Alpha-3 ISO format.

It also allows for some of the other variables used in the calculations to be adjusted as well.

const options = {
  dataReloadRatio: 0.6,
  firstVisitPercentage: 0.9,
  returnVisitPercentage: 0.1,
  gridIntensity: {
    device: 565.629,
    dataCenter: { country: "TWN" },
    networks: 442,
  },
};

Docs: https://developers.thegreenwebfoundation.org/co2js/tutorials/customise-website-carbon-calculations/

I'm open to contributing a PR if there's a desire for this functionality to be added to the IF model.

Hi @fershad thanks a lot for raising the issue - we would love it if you want to submit a PR. I'll assign the issue to you for now. If you have any questions drop them here in this comment thread! ๐Ÿ˜„

Hi @fershad any update on this?

@jmcook1186 I'll see how far I can get this week.

@jmcook1186 covered this off in #26

Merged in #26