{"id":47929947,"url":"https://github.com/cnumr/ecoindex_node","last_synced_at":"2026-04-04T07:15:00.846Z","repository":{"id":104271389,"uuid":"230822057","full_name":"cnumr/ecoindex_node","owner":"cnumr","description":"Calculates a webpage ecoindex (from http://www.ecoindex.fr)","archived":false,"fork":false,"pushed_at":"2024-05-17T10:27:13.000Z","size":18,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-09-10T04:39:25.954Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cnumr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-12-30T00:49:49.000Z","updated_at":"2024-11-16T21:49:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"992fe5b4-c4b5-480d-828f-01a9fa4aa465","html_url":"https://github.com/cnumr/ecoindex_node","commit_stats":{"total_commits":14,"total_committers":2,"mean_commits":7.0,"dds":0.4285714285714286,"last_synced_commit":"db94590447b957d09940db514998f42fcf24f8b4"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/cnumr/ecoindex_node","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnumr%2Fecoindex_node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnumr%2Fecoindex_node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnumr%2Fecoindex_node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnumr%2Fecoindex_node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cnumr","download_url":"https://codeload.github.com/cnumr/ecoindex_node/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnumr%2Fecoindex_node/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31391079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T04:26:24.776Z","status":"ssl_error","status_checked_at":"2026-04-04T04:23:34.147Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-04T07:14:58.629Z","updated_at":"2026-04-04T07:15:00.831Z","avatar_url":"https://github.com/cnumr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ecoindex\n\nThis Node.js module calculates a webpage's [ecoindex](http://www.ecoindex.fr)\n\n## Installation\n```bash\n$ npm install https://github.com/cnumr/ecoindex_node/tarball/master\n```\n\n## Usage\n```javascript\nconst ecoindex = require('ecoindex');\n\n/**\n * dom = number of HTML elements in DOM\n * req = number of external requests (images, css, frames, etc.)\n * size = total size of the page (including external requests) in ko\n * returns an object containing the ecoindex score (number between 0 and 100, higher is better), the grade (letter between A and G), the greenhouse gas emission and the water consumption\n **/\nvar index = ecoindex.getEcoindex(dom, req, size); // { score: 89, grade: 'A', ghg: 1.22, water: 1.83 }\n```\n\nFull example with [puppeteer](https://github.com/puppeteer/puppeteer) :\n```javascript\nconst zlib = require('zlib');\nconst puppeteer = require('puppeteer');\nconst ecoindex = require('ecoindex');\n\n(async () =\u003e {\n    var url = 'https://example.com';\n    var browser = await puppeteer.launch();\n    var page = await browser.newPage();\n\n    // get number of external requests\n    var req = 0;\n    await page.on('request', request =\u003e {\n        if (!request.url().startsWith('data:')) {\n            req++;\n        }\n    });\n\n    // get total uncompressed size\n    var size = 0;\n    await page.on('response', response =\u003e {\n        if (response.ok()) {\n            switch (response.headers()['content-encoding']) {\n                case 'br':\n                    response.buffer().then(buffer =\u003e {\n                        zlib.brotliCompress(buffer, function (_, result) {\n                            size += result.length;\n                        });\n                    });\n                    break;\n                case 'gzip':\n                    response.buffer().then(buffer =\u003e {\n                        zlib.gzip(buffer, function (_, result) {\n                            size += result.length;\n                        });\n                    });\n                    break;\n                case 'deflate':\n                    response.buffer().then(buffer =\u003e {\n                        zlib.deflate(buffer, function (_, result) {\n                            size += result.length;\n                        });\n                    });\n                    break;\n                default:\n                    response.buffer().then(buffer =\u003e {\n                        size += buffer.length;\n                    });\n                    break;\n            }\n        }\n    });\n\n    await page.goto(url);\n\n    // get number of DOM elements\n    var dom = await page.evaluate(() =\u003e document.querySelectorAll('*').length);\n\n    await browser.close();\n\n    // calculate ecoindex\n    var index = ecoindex.calculate(dom, req, Math.round(size / 1024));\n\n    process.stdout.write(index.toString());\n})();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnumr%2Fecoindex_node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcnumr%2Fecoindex_node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnumr%2Fecoindex_node/lists"}