6 Ways to Reduce Your Website’s Carbon Footprint – Built In

Cloud computing has abstracted our relationships with the hardware our websites run on. That’s led to environmental benefits, like the ability to scale applications up and down on demand, ending the need for every company to operate enough servers to keep up when traffic peaks. But it also means developers are further removed from the impact their code has on the physical world. 

And code does have an impact — it takes energy to run applications and transmit data, so inefficient and bloated code can add up to a significant environmental impact.

HOW TO REDUCE YOUR WEBSITE’S CARBON EMISSIONS

  • Get rid of unnecessary code. Don’t let large blocks of commented-out code slip into production.
  • Take advantage of compression. Some compression techniques can save data without compromising quality.
  • Choose efficient programming languages. Not all languages are equally efficient.
  • Run computations on the server side. Data centers are more efficient than end-user devices.
  • Choose green cloud vendors. Some vendors use sustainable energy sources and provide server-side efficiencies like caching.
  • Create a culture of efficiency. Companies can contribute by making digital efficiency a priority.

Tom Greenwood, co-founder of eco-conscious digital agency Wholegrain Digital, is happy to recommend steps the average developer can take to make a difference on the environment. His book, Sustainable Web Design, details many things developers, designers and tech companies can do to make a real difference through programming websites — and it’s a real and pressing need.

“The total annual emissions from the internet were somewhere around two percent of global emissions,” Greenwood said, “That’s roughly the same as aviation.”

The good news is that small changes can make a big difference, especially for applications with large user bases. A piece of code might run millions or billions of times in its life cycle, and the effects will be felt as long the code is deployed. Even if an application is made just slightly more energy efficient, the savings can be magnified many times over.

MORE ON GREEN COMPUTINGLooking to Go Green? Start With Modernizing Your Company’s Systems.

Reduce File Sizes By Using Compression

As Greenwood explains in his book, it’s hard to directly measure the carbon emissions of websites. The best way is to approximate by calculating how much energy an application consumes.

That’s related to the size of the application, often encapsulated by the concept of “page weight.” Page weight takes the size of the initial page as well as all the additional resources requested by the browser into account.

The average page weight for websites has steadily increased over the past few years. Today, the average page weight is 2 megabytes for both desktop and mobile applications — 10 years ago it was half a MB for desktop and less for mobile. Greenwood said resources like videos, large images and computationally intensive animations add lots of weight to websites. One of the most significant ways to reduce that weight is by cutting down on file sizes and trimming excess data using compression.

“In our experience, you can easily reduce the amount of data on a web page by 60 percent.”

“In our experience, you can easily reduce the amount of data on a web page by 60 percent,” Greenwood said.

Developers can start by reducing unneeded animations and deleting unused, commented-out code. They can also look for the most optimal file formats to use. For images, Greenwood recommended developers use the WebP image format developed by Google. WebP images are 26 percent smaller than PNG images and about 30 percent smaller than JPEG images of the same quality.

WebP manages these size savings through compression. While most people are familiar with compression for transferring data, such as using zip files, Greenwood said there are actually two different types of compression: one kind makes files unusable, like zip files, and another simply reduces the size of usable files.

“They’ve optimized the encoding of the image, so that the same image uses less data and just has a smaller file size,” Greenwood said. “You can make huge gains without any functional loss, really.”

Is Your Favorite Programming Language Energy Efficient?

Energy consumption doesn’t usually come to mind when developers choose between programming languages — but maybe it should. Greenwood said choosing the programming language is another way developers can have control over the carbon footprint of their application.

“Some programming languages are just inherently more energy efficient than others,” he said.

Research published earlier this year compared 27 different programming languages across different categories and found significant differences in energy use between languages. In the category of scripting languages, for example, PHP uses about seven times more energy than JavaScript.

“JavaScript, as a web language, is relatively efficient,” Greenwood said. “It’s not one of the most efficient like C or C++, but JavaScript is pretty good as a web language.”

That’s good news, because JavaScript is a popular language and growing in adoption. Developers can consider energy use an additional incentive to switch over for older web applications.

Keep Computations Server Side

Browsers are increasingly handling more of the work of rendering web applications. The trend started years ago with the move toward single-page applications, where new content was provided by browsers requesting specific data from the server rather than the server sending new pages.

That innovation helped with efficiency on the server side because it can cut down on the total amount of data sent, but the continuing trend with giving browsers more computational work isn’t great for efficiency

“Data centers are just better optimized for processing data efficiently, whereas end-user devices are relatively inefficient,” Greenwood said.

He encouraged developers to push their teams to do as much computational work on the server side as possible. But either way, developers can make computations more efficient by optimizing queries. Greenwood said there’s more opportunity to do that type of optimization in code that has some user interaction component to it, because the program has to calculate how to handle the user interaction.

Applications that have been layered with new functionality without streamlining are a good place to look for opportunities for optimization.

“Over time, you develop these features that become more and more complicated,” Greenwood said. “You might have a thing where in order to click yes or no, it’s actually going through some long sequence.”

Choose Green Hosting Services

In addition to page weight, the carbon emission of a website is tied to the energy sources used to power the company’s servers.

As companies move their servers to the cloud, they lose some direct control over the energy sources used to keep their servers humming — but they do have control over which cloud providers to use. Vendors offer a wide variety of choices, and even choosing which geographical locations servers should be placed in gives developers say over energy sourcing.

Differences in vendors can also go beyond energy sourcing. Some vendors offer server-side efficiencies like caching, so applications don’t have to be re-generated every time a user makes a request.

“The rate of change in digital can be really, really rapid compared to other industries.”

“Having some sort of hosting provider that will optimize that for you is just an easy win,” Greenwood said.

One of the biggest advantages for web developers is that these changes are relatively easy to make, he said. Even if companies can’t currently make the investment, or can’t find a suitable cloud hosting vendor, that doesn’t mean it’s not possible at some point in the future.

“There are no physical things that have to be remade, redesigned or remanufactured — whereas in an industry like aviation, there’s billions of dollars tied up in aircrafts that need to serve out their useful lives over the next 10 years or so,” Greenwood said. “So the rate of change in digital can be really, really rapid compared to other industries.”

Developers can help by staying on the lookout for opportunities to make changes when it’s possible and makes sense for their companies.

MORE ON TECH AND CLIMATEWhy Tech Plays a Crucial Role in Climate Change Research

Companies Can Develop an Environmental Narrative

Tech companies as a whole can help push for changes too. Greenwood said adjusting company objectives to take efficiency into account can make a big difference.

“Creating a culture of efficiency is probably the single biggest thing, because everything else will then just naturally spin off of that,” he said.

That can mean focusing development teams on eliminating unnecessary code and paying attention to page weight as part of their metrics. And the best news is, efficiency isn’t counter to most company’s overall objectives.

“A lot of companies do that in other areas of their businesses, like their logistics and their manufacturing,” Greenwood said. “But digital, in general, is more focused on building it fast and making it look cool, rather than ‘Let’s do it really, really well and make it really efficient.’”