/carbon-aware-site-worker

A Cloudflare Workers starter script that serves as the foundation for building a carbon-aware website.

Primary LanguageJavaScript

Make your website carbon aware

The concept of a carbon-aware website is one where the content/user experience of a site changes depending on how the grid intensity of the electricity grid. Implementing carbon awareness on this website was inspired by the work of Branch Magazine.

What is this?

This repository contains a Cloudflare Workers starter template that can be used to make a website carbon-aware. It is a very bare bones implementation, and is designed to serve as a launching pad, from which developers can begin to play around with the idea of carbon awareness on their own sites or apps.

You can read more about this at: https://fershad.com/carbon-aware-site/

Getting started

To start working with the code, clone this repository & run npm install in your console.

You will also need

Modifying code

All code for this project lives in the src/index.js file. I've left comments in there so that you can hopefully get a grips of how everything works.

Deploying

You can deploy this Cloudflare Worker using the Wrangler CLI. Run wrangler publish and follow the prompts.

To have the worker execute on specific page routes, you should update the wrangler.toml file to include a route key.