I recently read about this in Danny van Kooten’s blog post on the CO2 emission reductions he achieved through reducing the size of his Wordpress plugins.
I was inspired to see what efficiencies we could also make with our AddressFinder plugin. This story follows our investigation, challenges and how we were able to reduce our plugin size by 25%
AddressFinder plugin running on an address form
Can we reduce our file sizes too?
That got me wondering if AddressFinder could also make similar improvements. This would align with our company goals of having a reduced impact on the planet.
- An autocomplete library
- The AddressFinder business logic
- A cross-browser HTTP client
We realised that it may be possible to remove the HTTP client and the polyfills. These were included in the library to allow the service to work on very old browsers, including Internet Explorer 6 (which surprisingly is still used).
Challenges in supporting older browsers
The solution is to freeze the library at the current version. This frozen version would be returned to Internet Explorer (version 6, 7, 8 and 9) users.
This would then allow us to drop the support for those rather ancient browsers in the current version, and as a result the HTTP client and the polyfills could be removed.
We were able to carve off 5.9 kB with an end payload of 17.6 kB(compressed). A savings percentage of 25%
Emissions reduction calculation
The total download reduction in gigabytes is:
7.9 million * 5900 bytes * 1,000,000,000 = 46.6 GB network traffic
Danny’s blog post outlines an approach for calculating the amount of energy needed to transfer 1 GB of data across a modern network connection. He selected an average figure of 0.5 kWh of electricity used for each GB.
46.6 GB network traffic * 0.5 kWh/GB = 23.3 kWh electricity
Most of our customers are in Australia, so we will use the federal average emissions figure:
23.3 kWh electricity * 0.9 kg CO2 / kWh = 21 kg CO2 each month
What does 21 kg of CO2 look like?
Danny compares his emissions with those emitted by driving his car. Funnily enough, his car is a Toyota Yaris — which Matt also drives.
The Yaris has an efficiency of 158.5 g CO2/km.
To emit 21 kg of CO2, you would have to drive this far in the Yaris:
21 kg CO2 / 0.1585 = 132.5 km each month
As Danny says:
the most important thing is to realise that the choices we make in developing for the web have consequences that really add up at scale