https://github.com/krasimir/carboscope
A small JavaScript library to measure the carbon footprint of a web page
https://github.com/krasimir/carboscope
Last synced: 6 months ago
JSON representation
A small JavaScript library to measure the carbon footprint of a web page
- Host: GitHub
- URL: https://github.com/krasimir/carboscope
- Owner: krasimir
- License: mit
- Created: 2023-01-14T06:02:57.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-14T07:08:52.000Z (almost 3 years ago)
- Last Synced: 2024-10-03T13:39:18.531Z (about 1 year ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🌿 CarboScope
A <1KB JavaScript library to measure the carbon footprint of your page.
## Usage
*In the browser*
Copy/paste the content of [./dist/carboscope.js](./dist/carboscope.js) in the console on your page. Then run `CarboScope.measure()` or `CarboScope.measureOnce()`.
*In your app*
Run `npm install carboscope`. Then:
```js
import CarboScope from 'carboscope';CarboScope.measure(); // or CarboScope.measureOnce();
```## API
* `.asNumber()` - get the kg CO2e as a number
* `.measure(interval)` - calculate the emissions every two seconds and prints the result to the console. (The default value of `interval` is 2000ms)
* `.measureOnce()` - the same as `.measure` but it does it only once.## Formula
```
Carbon Footprint (kg CO2e) = MB * 0.5 kg CO2e/MB
```