Reduce your Wagtail and Django carbon footprint for Earth Day
Here are seven things you can work on to make your Wagtail and Django websites greener
With Earth Day coming up on April 22, this is a great time to start thinking about ways you can make your Wagtail and Django projects greener. Whether we like it or not, technology and software substantially contribute to carbon emissions. While big organizations and governments need to play their part, it's up to us as technology users and builders to learn all we can about reducing our impact on the planet.
We've estimated before that Wagtail websites alone produce around 8240 tons of CO2e/year. According to the Environmental Protection Agency's equivalency calculator, you can drive 19,118,334 miles (30,767,976 kilometers) or charge 493,488,045 smartphones with that amount of energy. That's a lot! Since Django has been around longer than Wagtail, those numbers are likely even bigger when you account for all websites that incorporate Django.
So, what can we do collectively to help bring those numbers down? I've pulled together some ideas on where you can start whether you can code or not.
Switch to a greener image format
If you do nothing else on this list, consider switching to using a greener image format like WebP or AVIF. Media is one of the biggest contributors of emissions on a website and making the switch is a relatively simple way to reduce your overall impact. I found in my own experiments with WebP that image sizes could be reduced by up to 60% without losing quality. Wagtail already has WebP and AVIF compatibility built in but it needs to be configured. If you're an editor and want to upload those formats, ask a developer nicely to help you switch it on (or bribe them with candy, whatever gets their attention). They can also make changes to your website templates so older image formats are automatically converted to newer formats whenever your website loads. Just keep in mind that not all design tools are embracing the new formats yet.
Learn how to measure your carbon impact
If you never know what your carbon impact is, then how can you possibly improve it? If you can only fit in two things from this list, then do this one in addition to updating your image formats so you can see the differences your changes make. There are different standards for measuring website impact out there, and the numbers you get for each one can vary. But the goal is to have a baseline number to work from. A great place to start is this page on tools for measuring metrics from the Green Web Foundation. Firefox has also recently added carbon measurements to their developer tools that you can use as well to track metrics. Some other open source tools you can check out include CodeCarbon (which is for all Python applications, not just websites), the Green Metrics Tool, Green Frame, and Scaphandre.
Use responsive image tags in Wagtail
If you're a developer, or you're already bribing your friendly neighborhood developer with candy to switch on the WebP and AVIF formats in Wagtail, add responsive image tags to the website templates too. These tags reduce the loading time for responsive images by generating all the needed images in one action rather than multiple actions. That leads to less server activity and ultimately fewer emissions.
Reduce videos and animations
Videos, animations, and GIFs are definitely attention-grabbing. Because they're ubiquitous on social media, many people assume everyone loves them. I mean, who doesn't enjoy watching this cat cuddle a teddy bear? The truth is that animations and videos can cause a lot of headaches behind the scenes due to their big, unwieldy file sizes. So many headaches that companies like X (formerly known as Twitter), started converting all GIFs to other file formats like MP4. Converting these files to a more modern format helps reduce their emissions impact. But to make the biggest difference, you should consider removing as many of them as you can without breaking your design and definitely remove autoplay as much as you possibly can.
Clean up your files
Your parents probably weren’t too impressed when you “cleaned up” by shoving all your stuff under the bed or in a closet as a kid. Unless they’re programmers or sysadmins, your parents most likely don’t care how clean your files are. But the Earth does. A substantial percentage of the persistent emissions created by computing technology comes from data storage. The more files you have, the more energy it takes to preserve them. You’re probably paying higher data storage costs to preserve them too. So save yourself some money and reduce some emissions by cleaning things up. The aging pages report and other reports in Wagtail are great tools for identifying old content.
Learn greener ways to code
The templating system in Wagtail and Django is great for repurposing code and breaking things down into reusable components. How you organize your templates though can effect the efficiency of your website. Providing specific recommendations is difficult because almost any frontend technology can be combined with Wagtail and Django. But the Web Sustainability Guidelines and the Green Software Patterns produced by the Green Software Foundation provide examples of greener code practices that you can adapt for your website. There are also suggestions out there for making AI greener as well.
Switch to a greener hosting service
If you want to go beyond making improvements to your own code, then consider moving your Wagtail or Django website to a greener hosting provider. The environmental impact of data centers and the infrastructure websites operate on is very high. So who you host with and what their environmental practices are really matters. The Green Web Foundation maintains a list of greener hosting services you can choose from in countries all around the world. If you can't switch hosting providers, you can also follow their steps for making your current setup more sustainable.
Optimize your website’s performance
Generally, the more efficient your website is, the fewer emissions it produces. Both Django and Wagtail have great documentation on how to improve performance. Wagtail has some very Wagtail-specific things you can improve, while a lot of Django's performance recommendations also apply to Wagtail since Wagtail is built on top of Django. If reading those docs is making your brain hurt, I'm pretty sure sysadmins are open to being bribed with candy too.
Hopefully, this list will inspire you to make some changes to your web practices for Earth Day. If you want even more ideas or to dig deeper into the standards, you can find a lot more in-depth information under Sustainability Considerations in the Wagtail docs. Whether you're an editor, a developer, a sysdmin, or a leader, there are plenty of changes everyone can take action on to make websites as green as they can possibly be.