Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sustainable Web Design Score in CO2.js #219

Open
benjaminrancourt opened this issue Jul 11, 2024 · 1 comment
Open

Sustainable Web Design Score in CO2.js #219

benjaminrancourt opened this issue Jul 11, 2024 · 1 comment

Comments

@benjaminrancourt
Copy link

If this isn't the most appropriate place to discuss this, forgive me. I preferred to do it here rather than attempt to have a discussion on a closed Merge Request.

In #207, the calculation of the score according to the Sustainable Web Design methodology was introduced in CO2.js, but I wonder about its implementation. In my understanding of the methodology, the score is based on the data transfer size, but the current implementation in CO2.js is, instead, based on the carbon emissions that have been calculated...

co2.js/src/helpers/index.js

Lines 258 to 298 in 8f95399

/**
* Returns the SWDM rating for a given CO2e value and version of the SWDM.
* @param {number} co2e - The CO2e value to rate.
* @param {number} swdmVersion - The version of the SWDM to use. Defaults to version 3.
* @returns {string} The SWDM rating.
*/
function outputRating(co2e, swdmVersion) {
let {
FIFTH_PERCENTILE,
TENTH_PERCENTILE,
TWENTIETH_PERCENTILE,
THIRTIETH_PERCENTILE,
FORTIETH_PERCENTILE,
FIFTIETH_PERCENTILE,
} = SWDMV3_RATINGS;
if (swdmVersion === 4) {
FIFTH_PERCENTILE = SWDMV4_RATINGS.FIFTH_PERCENTILE;
TENTH_PERCENTILE = SWDMV4_RATINGS.TENTH_PERCENTILE;
TWENTIETH_PERCENTILE = SWDMV4_RATINGS.TWENTIETH_PERCENTILE;
THIRTIETH_PERCENTILE = SWDMV4_RATINGS.THIRTIETH_PERCENTILE;
FORTIETH_PERCENTILE = SWDMV4_RATINGS.FORTIETH_PERCENTILE;
FIFTIETH_PERCENTILE = SWDMV4_RATINGS.FIFTIETH_PERCENTILE;
}
if (lessThanEqualTo(co2e, FIFTH_PERCENTILE)) {
return "A+";
} else if (lessThanEqualTo(co2e, TENTH_PERCENTILE)) {
return "A";
} else if (lessThanEqualTo(co2e, TWENTIETH_PERCENTILE)) {
return "B";
} else if (lessThanEqualTo(co2e, THIRTIETH_PERCENTILE)) {
return "C";
} else if (lessThanEqualTo(co2e, FORTIETH_PERCENTILE)) {
return "D";
} else if (lessThanEqualTo(co2e, FIFTIETH_PERCENTILE)) {
return "E";
} else {
return "F";
}
}

What is the reasoning for making such a change?

Thanks in advance for the explanations! 🤗

@fershad
Copy link
Contributor

fershad commented Sep 4, 2024

@benjaminrancourt Yes, data transfer is a key input for the Sustainable Web Design Model formula, however it's not the sole basis for estimating carbon emissions using that model. There are other factors (green hosting, caching, etc) that can also be applied. As a result, basing the rating system off the result of the carbon estimate allows these factors to also be considered, rather than it just being a straight 1:1 relationship with data transfer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants