Does performance work translate into energy savings?

Web technology has real electricity costs, and the question of whether those costs can be tied to specific techniques comes up often. Take a simple case: moving an element across the screen with a setInterval loop that increments the left position on a relatively positioned element, compared with a CSS @keyframes animation that changes a transform: translateX() value over the same duration. The JavaScript approach almost certainly draws more electricity. Normally we judge such choices by performance rather than energy, but that raises a broader question: do better performance scores track lower energy use?

Research suggests they do. A study of mobile web apps on Android, using Lighthouse scores, found a statistically significant negative correlation between performance scores and energy consumption, with medium to large effect sizes — as performance scores rise, energy use tends to fall. That likely carries over to other platforms and metrics.

We discover a statistically significant negative correlation between performance scores and the energy consumption of mobile web apps (with medium to large effect sizes), implying that an increase of the performance score tend to lead to a decrease of energy consumption.

Where the savings come from

The intuition is straightforward: the things that hurt performance are the things that consume power. Consider images. Serving oversized or unoptimized images dings performance scores, and the energy picture follows. Between a large image and a small one on a server, the large one takes more electricity to travel across the network to the user's machine, more processing power to parse and display, and more memory — which itself draws power — for as long as it stays on screen.

  • Less data sent across the network means less electricity.
  • Less work for the browser means less electricity.
  • An ad that auto-refreshes every few seconds wastes bandwidth and therefore power.
  • Polling with repeated network requests instead of event-based approaches such as web sockets spends electricity that may not have been necessary.

CDNs and the murkier trade-offs

CDNs are well established as a performance win: a file like an image comes from a server geographically close to the user, built for that job, instead of traveling across the world. Whether the same holds for low energy consumption is less clear. The question has been studied, though the conclusion isn't evident from the abstract alone.

Complications arise because servers worldwide hold copies of these assets, and when an asset changes, it updates on many servers rather than one. Some balance must exist between propagation and duplicate storage on one side, and the savings from efficient request handling on the other. Storage carries a similar tension. Files sitting on disk surely draw far less electricity than files moving over networks, but they still cost something. Keeping a copy of every file on every change, or a full copy of a site on every deploy, has clear utility — and a real energy price. Some balance has to be struck there too.

Dark mode, and technology comparisons

Dark mode is another area with published findings: research on popular Android apps found it can cut display power draw substantially.

Dark Mode can indeed reduce the display power draw by up to 58.5% at full brightness for the set of popular Android apps that we tested! In terms of whole phone battery drain reduction, that translates into 5.6% to 44.7% savings at full brightness and 1.8% to 23.5% savings at 38% brightness.

Comparing technologies is trickier. What a technology is doing likely matters far more than the language itself. An area that opens and closes via HTML's <details> element versus one built with a click handler on a button that toggles a class: the energy is probably dominated by the browser's repaint and re-render steps, not by the language driving them. The exception is when a choice brings extra weight — downloading a 50 KB JavaScript library just to implement that open/close element does matter, and the JavaScript version becomes the less efficient one.

The parallel holds: just as good performance generally maps to lower energy consumption, following the rule of least power generally maps to lower energy consumption as well.

Measuring a site's footprint

For a deeper treatment, Jack Lenox's Smashing article "How Improving Website Performance Can Help Save The Planet" covers the ground at length and points to testing tools, including the Website Carbon Calculator. Its methodology estimates emissions from five pieces of data:

Calculating the carbon emissions of website is somewhat of a challenge, but using five key pieces of data we can make a pretty good estimate:

1. Data transfer over the wire
2. Energy intensity of web data
3. Energy source used by the data centre
4. Carbon intensity of electricity
5. Website traffic

The testing code is open source.