Reduce your website’s environmental impact with a carbon budget
css-tricks.com
css-tricks.com
Where I agree with the article is to use tools like lighthouse and write code that uses the language properly. It is absolutely individual's responsibility to do this. The responsibility of making code efficient (dare I say "green") lies in those writing the browser engines/compilers.
0: https://medium.com/@mitpress/individualization-plant-a-tree-...
From the individual to the state and then the world, everything is continuously collective.
You just can't hope your institutions to change if a minority of citizen haven't proven lowering one's environmental impacts is possible, and made it socially desirable.
Then institutional change can happen.
In democraties at least, comsumer-citizens are necessary for the system to change.
Take a look at Code Complete: Chapter 25. Does a way better job explaining this than I could in a comment box.
I don't get it. Are they not doing that? Performance and battery life is a major selling point for browsers. If anything the biggest failure is at the individual developer/site level, not that firefox causes your fan to spin into overdrive when it tries to load a SPA monstrosity.
This starts to make sense when you consider that for Apple and Microsoft, end users are the customer and bad battery life is going to have implications on number of devices sold. For Chrome and a lesser extent Firefox, the “customer” is instead web devs, who are more interested in a constant stream of new features than they are efficiency.
That said, both browser vendors and site devs are responsible. It doesn’t matter how optimized the browser is if a site loads tens of megabytes of dependencies and is written with expediency and cheapness in mind only.
The problem is telling individuals to focus on optimization.
Let's use javascript as an example. Say you need to transform an array. You can use `.map` or a `for` loop in javascript.
You see a lot of articles like this https://dev.to/henryjw/array-map-much-slower-than-for-loop-5... that say a `for` loop is faster. And sometimes it's true.
By the logic of the original article, you should hyperoptimize your code. The problem is. If everyone writes `for` loops instead of using `map`. When map eventually becomes more efficient there's all that garbage code out there that has to be refactored.
Ignoring the problems associated with benchmarking - this for example claims map now being faster than for loops. https://leanylabs.com/blog/js-forEach-map-reduce-vs-for-for_...
It comes down to return on effort. We only have so much effort to put at solving this problem. You maximize your return on effort by having a clear separation of responsibility. In this case the individual's responsibility is to write code to the latest spec. The institution's responsibility is to make the code written as efficient as possible.
A single website saving .000000001 ppm of carbon (exaggerating) is just never going to be worth the effort. But a compiler improvement on all websites running javascript. Now that's totally worth it.
Further reading behind this logic: https://www.goodreads.com/book/show/3828902-thinking-in-syst...
https://stackify.com/premature-optimization-evil/
Code Complete (chapter 25.2) https://www.oreilly.com/library/view/code-complete-second/07...
For example recycling plastic is your responsibility - but what if your city burns plastic recycling? What do you do? Do you continue to buy plastic blame the companies for using it and the city for burning it? Why should the individual be penalized?
This seems more gray to me, like yeah okay I'm going to reduce the amount of plastic I buy in that case. And there are alternative like paper. In programming it feels more black and white. There is map and it serves a single purpose.
Unfortunately, while what you are saying is the conventional wisdom, it turns out that it’s also insidious propaganda from the plastic and beverage industry created to evade responsibility for their products.
According to the Changing Markets Foundation, which has extensively tracked the history of this issue
> the industry has successfully shifted the blame and responsibility for plastic pollution from the corporations to consumers and public authorities, all while promoting recycling as a convenient excuse to produce ever more plastic. We see how fake environmental groups and increasing numbers of new voluntary initiatives are used to distract from accountability, while legislation – such as plastic-bag bans and bottle bills – has been furiously fought against for years.
it is the fault of the product designers who take any advancement in the efficiency of technology as a excuse to push more crap. see: blockchain for the sake of blockchain, machine learning for the sake of machine learning, web apps for the sake of web apps
https://en.wikipedia.org/wiki/Carbon_footprint#Origin_of_the...
All guilt and responsibility is individual, as individual humans are the only ones with subjectivity and agency. Assigning blame to groups and "others" is extremely counterproductive. You either do what you can or you don't.
We can sit around trying to find scapegoats and and point fingers for a hundred years, and it's not going to do any difference. The consumers can blame the the producers, the producers can blame the consumers. The voters can blame the politicians and the politicians can blame the voters. The right can blame the left and the left can blame the right. Men can blame women and women can blame men. Cats can blame dogs and dogs can blame cats.
The reason it all sounds true is that every single one the accusations are true. Why yes, the producers are to blame, so are the consumers, the politicians, the voters. We are all to blame, we're all culpable for our decisions as individual humans. Each and every one of us all have responsibility.
So many of our business ideas are about reducing financial waste and often times that absolutely has an environmental component. If I’ve got a web app that’s reducing waste of some external resource (fuel, food, etc.), the positive external impact may be orders of magnitude more, and spending the effort to rewrite it in vanilla JS versus improving quality and fixing bugs may be time very poorly spent.
>No one is too small to make a difference.
And apparently no difference is too small to pursue.
Climate change is real, for sure, but we don't need to book-keep every single source of CO2 emission.
Data centers are a blip when it comes to CO2 emissions. That's why companies like microsoft and google can earn good citizen points by purchasing offsets. It doesn't cost a lot of money to offset because they aren't emitting a lot of CO2 in the grand scheme of things.
Amazon's logistics emit WAY more CO2 than AWS does. It's not even close.
So you have a lot of people walking around with the confidence of having earned a degree and completed an education, when they actually just have brain worms. And they're impervious to criticism to the point of arrogance, because they're College Educated.
I think the solution (or at least, something you personally could help do to change things) will be found in hiring practices. For open positions in fields not requiring specific specialized skills like the law, STEM, etc: stop requiring college degrees, and start using IQ tests or similar filters for those roles.
And if one really wants to save the planet by reducing page foot print, surely killing tracking and ads would be the place to start. Or just run an uBlock Origin.
Agree. Carbon emissions from client computing is probably a blip in terms other sources. Wasting resources (ie. cash spent on developers that could otherwise be allocated elsewhere) is counterproductive to the goal of reducing emissions as fast as possible. That's why I'm much more in favor of a carbon tax than random propositions that attract attention but have questionable efficacy (see also: plastic straw bans).
Some of the most popular languages are the least performative (we all know which ones). But they make life easier for developers, or as programmers love to say 'more productive'.
It's good to see new(ish) languages take performance seriously: Rust, Go, Nim, Crystal, Julia. I don't think it's controversial to say a typed, compiled language gives you good performance for free (and the reduced computing resources that implies).
When PHP 7 was released, Rasmus Lerdorf, the creator of PHP, said the performance improvements meant fewer servers, smaller memory use and reduced CPU activity - all of which equalled less power or electricity consumed. (And remember this is an interpreted language.) You can watch a segment from his presentation below where he talks about this, including the calculations he made of potential CO2 savings:
Rasmus Lerdorf – "PHP in 2018" (extract from the 15 min mark): https://youtu.be/umxGUWYmiSw?t=15m16s
When you consider the millions of servers in use, that additional language efficiency adds up to a substantial saving in electricity use. And yet among developers, a common response to performance issues is to say: hardware is cheap, just add another energy-guzzling server or use a more powerful computer.
The topic of ranking programming languages by energy efficiency has been discussed before on Hacker News. Here is the paper previously discussed which has been updated in 2021:
Energy Efficiency across Programming Languages: https://sites.google.com/view/energy-efficiency-languages
I don't think my website will be causing too many problems with the planet. Next I will be using mainly AVIF images for article images. Moreeeeee optimizations.
We need to be honest about how much energy is being spent on unnecessary activity.
If the data centers could run on cleaner energy, how much does that contribute to the CO2e measurements?
Maybe just fly to one less conference in your life time. It'll probably have more of an impact.
It feels a little weird to be doing math that's at this scale. We can debate whether computing power is a significant drive of climate change, and this sets off some greenwashing alarms for me, but I'm going to take it at face value and say, sure, we should have some conversations about power usage for applications. That being said, using an adblocker is basically just automating all of this article's advice -- it's reducing the amount of content that loads, reducing the amount of code that executes on each page. It's also fundamentally shifting away from the attention economy, removing some "traps" that try to get people to stay longer on websites than necessary.
And when you install an adblocker on your phone/desktop, these environmental improvements are included on virtually every single page you visit, regardless of what the engineers tried to do. It's a quick way to reduce the carbon footprint of all the websites you visit, immediately. And every single consumer can do it, it has basically no individual downsides, it doesn't require a personal sacrifice.
It feels weird that the top suggestions coming out of all of the sources that the author links to are basically saying "make your website show less unnecessary crud" and "make your website do less unnecessary crud", but there's not an acknowledgement or a reflection that the attention economy is one of the biggest reasons why websites do stuff like this. A call to Google to make things better, when Google's entire business model is based around making people look at their phones more and keep their phone screens on longer... it just kind of feels like missing the forest for the trees. You know why Youtube shows animated previews of all of its videos when you hover on them: because it gets people to click on videos more endlessly. Talking about the power consumption of the initial render for React, or whether or not Youtube is using CDNs effectively enough is really kind of ignoring the bigger picture of what the web is and why it works this way.
So if you care about this, sure, write more efficient code, whatever. That's not bad to do. But if you really want to practically reduce the web's carbon footprint, then undermine the attention economy and hasten the collapse of the ad industry, and try very hard to contribute to starting a social movement/trend where consumers block ads. Unless you are in charge of something massive, that will have a larger impact than any individual code optimizations you make.
I don't accuse the author of this at all, I take the author at face value. Outside of the author, we spend a lot of time trying to guilt individuals about systems that are designed to work a certain way, and we are often very hesitant to go beyond guilting individuals and questioning whether the larger systems we've designed should also be asking these questions. It is not individual designers being bad at SEO that are producing the majority on the Internet, it's ads. And it is fundamentally impossible to get everyone on board with the idea that websites should statically represent information quickly and then get people off them -- when the business model we have chosen for the Internet relies on eyeballs staying on pages looking at ads for extended periods of time.
If we're not willing to have that conversation and if we're only willing to talk about this stuff in abstract terms, then guilting individual developers about the environmental costs of using React is kinda greenwashing, because I don't think it's React's fault that news sites have auto-playing videos and animated ad banners. It feels like organizing the silverware drawer while the house is burning down around you. If this is a pressing issue, then instead of researching the best compression techniques for code bundling, take that same amount of time you would have spent doing that, and instead send your friends illustrated tutorials about how Ublock Origin works, or instructions on how to set up adblockers on their Android phones.
You can also consider installing SponsorBlock on Youtube, which will auto-skip sponsor segments and intro segments in videos, which will reduce the amount of time you spend rendering out videos. You can also consider installing NewPipe on Android, which allows you to block recommendations on videos, which is super helpful because you'll just flat-out spend less time watching Youtube. NewPipe also has a fork that integrates SponsorBlock.
You can teach people how to download music/videos from Youtube, which will reduce the amount of power/data they stream. There's a lot of options here that we could explore from an environmental perspective. They're not good for Google, but I don't really care about that? I guess what I'm saying is that if you're concerned about power usage for devices, that's great, but consider widening the number of potential solutions that you're looking at and consider being more willing to look at solutions that are not just nice things that get posted to blogs that engineers at Facebook can feel safe sharing with each other. There are articles being linked from this one that talk about cutting down on "thank you" emails. Like... no, burn the ad industry to the ground or stop wasting my time.