This project provides methods for the EcoIndex calculation.
It is based on the work of the association GreenIT and the web extension GreenIT-Analysis.
The sources are based on the initial Web Extension (https://github.com/cnumr/GreenIT-Analysis/blob/master/script/ecoIndex.js) code. The calculation method is discribed on here : (EcoIndex pouplation)
Install package with npm
npm install ecoindex
computeEcoIndex
returns the ecoIndex according to 3 parameters.
Name | Type | Description |
---|---|---|
dom | number | Number of DOM elements |
req | number | Number of requests |
size | number | Size of response (Ko) |
import {computeEcoIndex} from "ecoindex";
const ecoIndex = computeEcoIndex(dom, req, size);
getEcoIndexGrade
returns the grade according to the ecoIndex value.
Name | Type | Description |
---|---|---|
ecoIndex | number | The EcoIndex value |
import {computeEcoIndex, getEcoIndexGrade} from "ecoindex";
const ecoIndex = computeEcoIndex(dom, req, size);
const grade = getEcoIndexGrade(ecoIndex);
We use mocha for testing. You can launch tests using this command :
npm test
The LCA values used by ecoindex to evaluate environmental impacts are not under free license - ©Frédéric Bordage
Please also refer to the mentions provided in the code files for specifics on the IP regime.