Code/assets/impact_co2.js
Fabrication du Numérique fbe196e166 Évolution schéma
2025-04-30 21:29:54 +02:00

15 lines
488 B
JavaScript

import tgwf from "https://cdn.skypack.dev/@tgwf/co2";
export function calculerImpactCO2(totalBytes) {
const emissions = new tgwf.co2();
const greenHost = true;
let estimatedCO2 = emissions.perByte(totalBytes, greenHost).toFixed(1);
let totalMB = (totalBytes / (1024 * 1024)).toFixed(1);
const target = document.getElementById("network-usage");
if (target) {
target.innerHTML = `Transfert : ${totalMB} Mo<br>CO₂eq estimé : ${estimatedCO2} g`;
}
}