@grantcodes/footprint
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

Footprint

A small tool to estimate the CO2 output of every resource on a webpage using CO2.js and the performance API.

Installation

npm install @grantcodes/footprint

Usage

import { Footprint } from "@grantcodes/footprint";

const footprint = new Footprint(performance);

// Get an array of all loaded resources. 
const resources = footprint.resources;
resources.foreach(result => console.log(result.name, result.co2));

// Can also get results for a specific category ("media" | "js" | "css" | "html" | "other").
const cssResources = footprint.getByCategory("css");

// And get totals for the resources
console.log(`The ${cssResources.totalBytes} bytes of css resources on this page are estimated to generate ${cssResources.totalCo2} of CO2`);

Readme

Keywords

none

Package Sidebar

Install

npm i @grantcodes/footprint

Weekly Downloads

14

Version

1.0.9

License

MIT

Unpacked Size

13.8 kB

Total Files

7

Last publish

Collaborators

  • grantcodes