thegreenwebfoundation / co2.js

An npm module for accessing the green web API, and estimating the carbon emissions from using digital services
Other
375 stars 47 forks source link

Remove Page X-ray specific functions #182

Closed fershad closed 3 months ago

fershad commented 7 months ago

Describe the bug There's a bunch of Page X-ray specific functions in the CO2.js library. This isn't specific to any model. I am not aware of any other user (besides sitespeedio/sitespeed.io) who are using these functions.

@soulgalore would it be possible to move these functions into the Sitespeed sustainbility plugin itself? That would help reduce the code we ship with the library (#121) as well as reduce the size of our tests.

We would not make this change for a few months, and would socialise it with the community to try and ensure no other projects are impacted.

Additional context https://github.com/thegreenwebfoundation/co2.js/blob/51b85e23dc1f52ac6642259c09e56fef62948087/src/co2.js#L190-L290

soulgalore commented 7 months ago

Hi @fershad yes let's move them, I can do that the coming week, I'll ping the issue when I'm done or if I get into trouble.

fershad commented 7 months ago

Thanks @soulgalore. No rush to get this in, I don't see us making the change at our end until late Jan or Feb 2024.

soulgalore commented 7 months ago

@fershad that is merged in sitespeed.io, going out in a release before Christmas. I think it actually would be cool if co2 provided that data but you could collect it directly from a HAR file to get rid of the PageXray dependency.

mrchrisadams commented 7 months ago

hey @soulgalore , @fershad - I think what Peter raises is a good point that we might touch on in future.

We know right now that different calculators make different assumptions how they aggregate figures per domain - this likely goes some way to explaining why Ecograder, Sitespeed, and Webpagetest can have slightly different figures for the same page.

If this kind of functionality isn't in CO2.js, it might be worth at least us documenting the different approaches used to provide the per-domain figures.

I think some calculators use a global annual co2 intensity figure, and others use a national annual figure, and some even use national hourly figure from a source like electricity maps.

I've created #183 to capture this discussion for future reference.