Your website carbon footprint and how to improve it
Every website has it's own carbon footprint. I will tell you how to measure it and how you can improve it.
Most of us either have a website or are building websites, as I do. However, one thing that is mostly overlooked is the carbon footprint of a website. In a time when the industry is busy lowering its carbon footprint, it is more important than ever to invest in this aspect.
Most people are not aware of how much energy the internet uses on a global scale. Research estimates that by 2025, the IT industry could use 20% of all electricity produced and emit up to 5.5% of the world’s carbon emissions. Looking at the energy usage of the internet alone, that is 416.2TWh! While the carbon emission number is not that big, we should always aim for a more sustainable internet that runs on green energy, like wind, water, or solar energy.
How do I measure my website's carbon footprint?
While there are multiple ways to calculate the carbon footprint of your website, none will be perfect and will only work as an indication. For my own websites, I have chosen to use the calculator on the website websitecarbon.com. You can simply submit the URL of your website, and in a few minutes, you get your score. In the case of my Microblog, it only uses 0.02g of CO2/view. This is extremely low for a website. Most websites will be a lot higher than that. I have also tested my WordPress website, and that got a score of 0.37g of CO2/view. The average carbon footprint of a site is 0.846g of CO2/view based on the information from the Website Carbon Calculator.
How can I lower my website's carbon footprint?
There are multiple ways to reduce the carbon footprint of your website, such as optimizing your images, reducing the amount of JavaScript, avoiding WordPress or other frameworks, or opting for a green web hosting company.
Reduce image size
The easiest thing that everyone can do is to reduce the number of images and keep the file size of each image low. Don’t include images that are 3MB in size on a website, but reduce them to an acceptable size of 300KB.
As a real-life example, a few weeks back, I saw a webpage that had a total size of 100MB! This was only because the client decided to use multiple SVG image files with a size of 12MB each. Firefox was even unable to handle this webpage. The carbon footprint of this page is 18.22g of CO2/view and is ranked as an F. Based on 10,000 monthly page views, this will output yearly 2.186kg of CO2 with an energy usage of 5.705 kWh. That’s a lot! While this might be an extreme example, it just shows how easy it is to make mistakes that have a big impact on your website's carbon footprint.
Reduce JavaScript size
You can also reduce a lot by lowering the amount of JavaScript on a website. Lots of websites are using too many JavaScript libraries when that is often not needed. Most of the scripts can be reduced or replaced with lightweight scripts that don’t require jQuery or other libraries. Another trend is websites built with JavaScript frameworks, like Angular or React. You should really think twice if those frameworks are required for your website. In some cases, they can be useful, but in my opinion, you should only opt for those when you’re building an application.
Don’t choose a framework
This one might be hard as frameworks make your work as a developer a lot easier most of the time. Most of the time, this is not even a choice as it already exists in the project or is defined by the policy of the company or client. The reason why I added this point to the list is that most of the bigger frameworks have a lot of overhead. Ninety percent of the code that exists in a framework you never need and just makes your website heavier and costs a lot more energy. The most simple rule, in my opinion, is just to keep your code simple and light.
As an example for my Microblog, I had the choice to install WordPress, select a bloated theme, and write my blogs in there. But I chose to build it myself. The script contains just the basic PHP code, without any overhead. All this makes it possible to render the website as fast and light as this.
Choose a green web host
Your website can be as fast and optimized as possible, but if your web server is running on a coal power plant, everything you have done is for nothing. You should inquire if your web hosting is running on sustainable energy. If you might want to look around and pick one which is greener. It might be that some companies are engaging in greenwashing. But this is still better than nothing.
Final word
As a full-stack PHP developer, I am fully aware that not all of the above points are realistic or might be extreme. Also, the carbon footprint numbers are just an indication and might not match the real number. However, it is still an indication you can use to improve your website or show your boss or client that they need to improve the website. In the end, a lower number is always better, and we developers should always opt for a better sustainable internet.
「説明する必要はありません。もう私は自分のすることを知っています。 - ユウナ。」— There's no need to explain. I already know what I'll do. -- Yuna, FFX.