zachleat / performance-leaderboard

A plugin to run Lighthouse against a set of urls to see which site is the fastest.
97 stars 12 forks source link

Introduce Carbon footprint #7

Closed dgrammatiko closed 4 years ago

dgrammatiko commented 4 years ago

This is a better implementation of #6

It uses the www.websitecarbon.com API and adds one more dependency for Axios.

An example of the expected result is: Screenshot 2020-09-11 at 15 37 40

The carbon object in detail: Screenshot 2020-09-11 at 16 11 56

zachleat commented 4 years ago

Looks great! Any way we could make this opt-in, the data collection portion makes me nervous as a default:

By using this carbon calculator, you agree to the information that you submit being stored and published in our public database.

dgrammatiko commented 4 years ago

Any way we could make this opt-in, the data collection portion makes me nervous as a default

Yeah that's a good point, data collection might be a problem. https://github.com/zachleat/performance-leaderboard/pull/7/commits/0b34f5f9ac03bc047bb38d2438237f6fbd180772 should allow the conditional run of the audits. By default it will skip the carbon auditing (you can simply flip the https://github.com/zachleat/performance-leaderboard/blob/0b34f5f9ac03bc047bb38d2438237f6fbd180772/performance-leaderboard.js#L15 to enable it by default or pass an option await PerfLeaderboard(urls, 3, {carbonAudit: true}) in the arguments

zachleat commented 4 years ago

Excellent—thank you!