Skip to content

feat: calculate emissions from page speed results#10

Closed
jonoliver wants to merge 0 commit into
mainfrom
feat--calculate-emissions
Closed

feat: calculate emissions from page speed results#10
jonoliver wants to merge 0 commit into
mainfrom
feat--calculate-emissions

Conversation

@jonoliver

@jonoliver jonoliver commented Nov 18, 2025

Copy link
Copy Markdown
Member
  • Add function to calculate emissions from Google PageSpeed results
  • Install @tgwf/co2
  • Add bundle script to bundle the above dependency for use in the browser

TODO

Validation

  1. npm run build
  2. Load the extension in the browser
  3. Navigate to https://sparkbox.com/ and open the devtools js console
  4. Open the extension and click "Analyze this page"
  5. Wait for the page scan to complete. Verify that you see the calculation results in the js console: Emissions Calculation Results: {bytesTransferred: 1899035, totalCO2: 0.28143698699999997}

@jonoliver jonoliver force-pushed the feat--calculate-emissions branch from f569f90 to caddabd Compare November 18, 2025 19:08
@github-actions

github-actions Bot commented Nov 18, 2025

Copy link
Copy Markdown

📦 Extension packages built successfully!

Download your Chrome and Firefox extension packages

@jonoliver jonoliver force-pushed the feat--calculate-emissions branch from caddabd to a6d43f8 Compare November 18, 2025 19:12
@jonoliver jonoliver force-pushed the feat--calculate-emissions branch 2 times, most recently from 1af9ab6 to 17fbcdc Compare December 2, 2025 21:13
Comment thread bundle.js
}

module.exports = { bundleCarbonCalculator };

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't have anything bundling our js for the browser, and this is the first time that we're importing a 3rd party npm package @tgwf/co, e.g:
import { co2 } from "@tgwf/co2";

Since deps from node_modules weren't being bundled, trying to import resulted in this error when running the extension in the browser: TypeError: Failed to resolve module specifier "@tgwf/co2".

This is kind of a quick and dirty solution that just bundles the carbon calculator with the underlying dependency. We could probably improve this by bundling each entry point js file along with their underlying deps, but that's bigger than the scope of this PR.

@jonoliver jonoliver marked this pull request as ready for review December 2, 2025 21:32
@jonoliver jonoliver force-pushed the feat--calculate-emissions branch from 17fbcdc to d127d73 Compare January 13, 2026 17:51
@rise-erpelding rise-erpelding self-requested a review January 13, 2026 18:50
@jonoliver jonoliver closed this Jan 27, 2026
@jonoliver jonoliver force-pushed the feat--calculate-emissions branch from d127d73 to 98c8b55 Compare January 27, 2026 18:17
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

Successfully merging this pull request may close these issues.

2 participants