Code feels weightless. You write a function, it works, and nothing in the experience suggests a physical cost.
But every loop runs on a processor somewhere, every request crosses a network, and every unnecessary kilobyte is parsed on a device held by a person whose battery is at nineteen per cent. Code is a physical resource that happens to be invisible at the point of writing.
Sustainable coding practices are the habits that keep that cost proportionate to what the code achieves. They produce faster sites as their first effect, which is why the argument holds regardless of what you think about the environmental case.
Sustainable Coding Practices: Building Efficient and Sustainable Websites
Ship less JavaScript
This is the single largest lever, and it is mostly a question of restraint rather than skill.
Most sites carry frameworks doing work that markup and a small amount of script would handle. A component library imported for two components. A date formatting library for one date. A carousel dependency for a carousel nobody swipes.
Audit dependencies periodically, because they accumulate quietly through ordinary development. Ask of each one whether the problem it solves is still present, and whether the platform now solves it natively. A surprising number of utility libraries answer questions that browsers answered several years ago.
JavaScript is also the most expensive thing you send, byte for byte, because it must be downloaded, parsed, compiled and executed. An image of the same size is merely downloaded and decoded.
Prefer the platform
Semantic HTML costs nothing to download, works without script, and gives assistive technology what it needs by default. A `<button>` element is keyboard operable, focusable and announced correctly without a line of JavaScript. A `<div>` styled to look like a button is none of those things until you rebuild them all.
CSS handles a great deal that is routinely done in script: transitions, transforms, layout, sticky positioning, aspect ratios, container queries. Browser-native solutions are faster because they run in optimised code paths rather than in your bundle.
The general principle is that the platform is cheaper than your abstraction over it, and it is maintained by somebody else.
Reduce requests, then reduce their size
Every request has overhead beyond its payload: connection setup, headers, and latency that is felt disproportionately on mobile networks.
Consolidate where it helps, and remove entirely where you can. Third-party scripts deserve particular scrutiny, since each one typically opens a new connection to a domain you do not control and executes code you have not reviewed.
Then attend to size. Compress assets, subset fonts to the characters you use, serve images at display dimensions in modern formats, and lazy-load anything below the fold.
Cache with intention
A returning visitor should not re-download assets that have not changed. Sensible cache headers are among the cheapest efficiency improvements available and among the most commonly neglected.
Set long lifetimes on fingerprinted static assets, short ones on content that changes, and make sure your deployment process invalidates correctly. Caching that serves stale content is worse than none, because the failure is confusing rather than merely slow.
Measure, then be careful what you claim
Record page weight, request count and Core Web Vitals for your most-visited pages under stated conditions: device, connection, first or repeat visit. Without a baseline, you can assert an improvement but not demonstrate one.
The HTTP Archive page weight report gives you a benchmark to compare against rather than an abstract target.
Carbon estimation tools produce a directional figure derived from page weight and hosting assumptions. Two tools can disagree about the same page. Use one consistently, state which, and treat the trend as more meaningful than the number.
Where performance and environmental impact both apply, treat them as the same lever. Reducing unnecessary data transfer and processing supports a faster experience while lowering estimated digital carbon, though those environmental figures remain modelled rather than directly measured.
Auditing existing code
Start with what is loading rather than what is written. Open the network panel on a real page and look at what actually arrives: the sizes, the third parties, the things you do not recognise.
The things you do not recognise are usually the win. Tags for tools abandoned a year ago, libraries loaded on every page for a feature on one, fonts in weights nobody uses.
Then look for redundancy. Two libraries doing the same job. Analytics running twice because one was added by marketing and one by development. Polyfills for browsers nobody uses any more.
Refactor in small, measurable steps and record the result each time. A single large rewrite is harder to justify and harder to reverse when something breaks.
Our sustainable web development work builds this measurement into delivery rather than bolting it on afterwards.
