6 ways to reduce your website’s carbon footprint
Cloud computing has ignored our relationship with the hardware our websites run on. This has resulted in environmental benefits, such as the ability to scale applications on demand, ending the need for every business to operate enough servers to keep up with spikes in traffic. But it also means that developers are even further removed from the impact of their code on the physical world.
And code has an impact – it takes energy to run applications and transmit data, so inefficient and bulky code can add up to significant environmental impact.
HOW TO REDUCE CARBON EMISSIONS FROM YOUR WEBSITE
- Get rid of unnecessary code. Don’t let large chunks of commented code go into production.
- Take advantage of the compression. Some compression techniques can save data without compromising quality.
- Choose efficient programming languages. Not all languages are equally effective.
- Perform the calculations on the server side. Data centers are more efficient than end user devices.
- Choose green cloud providers. Some vendors use sustainable power sources and offer server-side performance such as caching.
- Create a culture of efficiency. Businesses can help by making digital efficiency a priority.
Tom Greenwood, co-founder of environmentally 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 website design, details many things that developers, designers, and tech companies can do to make a real difference through website programming – and it’s a real and urgent need.
“The total annual emissions from the Internet were about 2% of global emissions,” said Greenwood, “it’s about 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 can execute millions or billions of times during its lifecycle, and the effects will be felt as long as the code is deployed. Even if an application is slightly more energy efficient, the savings can be magnified many times over.
Reduce file size using compression
As Greenwood explains in his book, it’s difficult to directly measure website carbon emissions. The best way is to approximate by calculating the amount of power consumed by an application.
This is related to the size of the application, often encapsulated by the concept of “page weight”. The page weight takes into account the size of the initial page as well as any additional resources requested by the browser.
The average page weight of websites has steadily increased over the past few years. Today, the average page weight is 2 megabytes for desktop and mobile apps – 10 years ago it was half a megabyte for desktop and less for mobile. Greenwood said resources like videos, large images, and compute-intensive animation add a lot of weight to websites. One of the most important ways to reduce this weight is to reduce file sizes and trim excess data using compression.
“In our experience, you can easily reduce the amount of data on a web page by 60%. “
“In our experience, you can easily reduce the amount of data on a web page by 60%,” Greenwood said.
Developers can start by reducing unnecessary animation and removing unused, commented out code. They can also search for the most optimal file formats to use. For images, developers recommended by Greenwood use the WebP image format developed by Google. WebP images are 26% smaller than PNG images and about 30% smaller than JPEG images of the same quality.
WebP manages these size savings through compression. While most people are familiar with compression for data transfer, such as using zip files, Greenwood said that there are actually two different types of compression: one type makes files unusable, such as files. zip, and another just reduces the size of the usable files.
“They optimized the encoding of the image, so 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?
Power 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 for developers to control their application’s carbon footprint.
“Some programming languages are just inherently more power efficient than others,” he said.
Keep server-side calculations
Browsers are increasingly handling the work of rendering web applications. The trend started years ago with the move to single page applications, where new content was delivered by browsers requesting specific data from the server rather than the server sending new pages.
This innovation has helped efficiency on the server side as it can reduce the total amount of data sent, but the trend continues to give browsers more computational work is not great for efficiency.
“Data centers are just better optimized to process data efficiently, while end-user devices are relatively inefficient,” Greenwood said.
He encouraged developers to push their teams to do as much server-side compute work as possible. But in any case, developers can make calculations more efficient by optimizing queries. Greenwood said there are more opportunities to do this type of optimization in code that has a user interaction component, because the program has to calculate how to handle user interaction.
Apps that have been layered with new functionality without streamlining are a good place to look for optimization opportunities.
“Over time, you develop these features that get more and more complicated,” Greenwood said. “You might have one thing where to click yes or no actually goes through a long streak.”
Choose green hosting services
In addition to the weight of the pages, a website’s carbon emission is related 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 power sources used to run their servers, but they do have control over which cloud providers to use. Vendors offer a wide variety of choices, and even the choice of the geographic locations in which the servers should be placed gives developers a say in the supply of power.
The differences between providers can also go beyond energy supply. Some vendors offer server-side efficiencies like caching, so applications don’t need to be refreshed every time a user makes a request.
“The rate of change in digital can be really, really fast compared to other industries. “
“Having some sort of hosting provider that will optimize this 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 though businesses can’t invest currently, or can’t find a suitable cloud hosting provider, that doesn’t mean it won’t be possible at some point in the future.
“There are no physical things that need to be redone, redesigned or refurbished – whereas in an industry like aviation billions of dollars are tied up in planes that must reach their useful life over the course of time. the next 10 years or so, ”Greenwood said. . “So the rate of change in digital can be really, really fast compared to other industries. “
Developers can help by staying on top of opportunities to make changes where possible and makes sense for their businesses.
Businesses can develop an environmental narrative
Tech companies as a whole can help shake things up as well. Greenwood said adjusting company goals to factor in efficiency can make a big difference.
“Creating a culture of efficiency is probably the most important thing, because everything else will flow naturally from it,” he said.
This 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 doesn’t run counter to the overall goals of most businesses.
“A lot of companies are doing this in other areas of their business, like their logistics and manufacturing,” Greenwood said. “But digital, in general, is more about building it fast and looking cool, rather than ‘Let’s do it really, really well and make it really efficient.’