-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add Sustainable Web Design rating scale #207
Conversation
@mrchrisadams are you comfortable with this getting merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @fershad - this looks great!
I have a query about using constants in place of some of the values, that only have explanation on external websites like the 0.95
figure referring to the fifth percentile of websites in the SWD model page, but otherwise I'm happy to merge it in.
Please merge in at your convenience.
Triage
Type of change
Please select any of the below items that are appropriate.
This pull request:
Related issue/s
Please list below any issues this pull request is related to.
Docs changes required
Do any changes made in this pull request require parts of the CO2.js documentation to be updated?
If you answered "Yes", please create an corresponding issue in our Developer Documentation repository.
Related issue: thegreenwebfoundation/developer-docs#50
Describe the changes made in this pull request
As clearly as possible, describe the changes made in the pull request. You should at least detail "what changes have been made" and "what the results of these changes will be".
This change adds the Sustainable Web Design rating scale into CO2.js for developers using the Sustainable Web Design Model to estimate emissions.
The rating scale is "off" by default, but developers can opt-in to returning results with a carbon emissions total & a corresponding rating by setting
rating: true
when instantiating an instance of the Sustainable Web Design Model in CO2.js.The rating system is based on the
number of bytes passed intocarbon emissions results calculated by theperByte
,perVisit
,perByteTrace
, orperVisitTrace
functions.Currently the
perByte
andperVisit
functions return a number representing the estimated CO2e calculated by those functions. Whenrating: true
is set, these functions will now return an object with two keys -rating
andtotal
. For example: