Skip to main content
Open npm widget
cometweb.io/carbon-badge Live

Carbon Badge

Embed a lightweight CO₂e badge — api mode (Insight) or estimate (local).

Open-source web component @cometweb/carbon-badge (MIT). api measures a URL via the public API; estimate uses the current page’s Performance API weight. Transfer estimate — not an ESG certificate.

mode=api — Insight public API measures the given URL (here: cometweb.io).

1. Install
Then: import '@cometweb/carbon-badge' in your bundler. Pinned version: 1.0.6.
2. Drop in your page
mode=api — Insight public API measures the given URL (here: cometweb.io). Component default mode is api. Tag: cometweb-carbon-badge (not carbon-badge).
Attributes
urlURL for API (defaults to current). In estimate it does not drive page weight.
modeapi | estimate — default api
themedark | light
cache-ttllocalStorage cache minutes (default 720 = 12h). Within TTL: last successful result. After expiry: re-fetch API; on rate-limit/timeout → estimate fallback; on hard failure → error state (no invented grade).
api-urlhttps://app.cometweb.io/api — public, no auth; 10 req/min/IP; max 20 unique URLs/h/IP
green-hostestimate only — "true" lowers hosting factor
Score thresholds (g CO₂e / visit)
A+< 0.10g
A< 0.20g
B< 0.40g
C< 0.70g
D< 1.00g
F≥ 1.00g

This estimates page transfer emissions — not an org-wide footprint or ESG certificate.

SWDM v4 model

CO₂e estimate via the Sustainable Web Design Model (Green Web Foundation). API responses also expose Insight formula_version.

~4.7 KB gzip

@cometweb/carbon-badge@1.0.6 — zero runtime dependencies.

api or estimate

api: GET /api/public/carbon-badge (no auth). estimate: local Performance API — no API calls.

theme dark / light

Two built-in web component themes — no custom CSS required.

MIT license

Open source: use commercially, self-host, modify — no fee for the widget.

Public API limits

Free, no auth. Limit: 10 req/min per IP; max 20 unique URLs/h per IP. Server cache ~12h. For high traffic use mode=estimate.

Links to Ecology

Click opens cometweb.io/insight/ecology (module page), not an ESG certificate or a full project report.