rikard.me/blog/010.txt Sun 14 Jan, 2024 The modern web is bloat I recently got a Thinkpad X220. This year it will be 13 years old, but despite its modest specs it runs all the software I use without any performance issues. I use 'sway', a very lean window manager. I do most of my computing in Emacs which I run inside 'foot'. Most of my other computing I manage with common Unix utilities. This laptop is great for this. On a full battery I can use it for about four hours. The 2.5GHz Intel i5-2450 usually has a load of around 0-5%; out of the 8G RAM no more than 400M is used at any time. Until I open Firefox. Battery life drops to an hour. CPU load goes to 50%; RAM to 30-40%. Doing the most trivial task on the web requires running more complex software than was needed to put men on the moon. To read a news article I have to run countless JavaScript programs; my browser has to compute hundreds of lines of CSS, and make calls to dozens of external sites. The web would be a better place if people actively thought about performance when designing their sites. A news site or a blog has no reason to not have its (textual) content loaded and drawn on the screen in less than a second. What can be done to improve this mess? Some ideas: - Impose limits. Some of the best software was written when computer resources were limited. Programmers were forced to make their programs efficient. Today, thanks to hardware advancements, software developers don't have to optimise their code. Since there are no actual limits, artificial ones should be imposed. Attempt to make websites in as few lines of code as possible. Use as little CSS as possible. Less is more. - Avoid loading external content. Latency adds up. - Avoid the unnecessary. This is something best practised in many parts of life, but especially so in software design. You could actually rationalise the two previous suggestions into this. Is it really necessary to load ten different fonts from as many third-party websites? Or to have a pop-up advertising your newsletter (or to have a newsletter to begin with)? I would say that this thinking should also extend to the content you put on your website. If you're sharing a cooking recipe, just share the recipe, don't write 1K words on where the dish is from, or what it means to you. That kind of reflective writing is best suited for a blog. JavaScript is the work of the devil, and anyone who puts this deranged form of programming into practice should be burnt at the stakes. However, if a site somehow needs JavaScript: - Consider if it's _actually_ necessary, or if your website could deliver the same content without it. - If you somehow can't manage without it, then write vanilla JavaScript. Think in terms of simplicity, and don't use overly complex frameworks for simple functionality. - Make it optional. Users who disable JavaScript should still be able to access and use your site. - If you write a nontrivial program, respect its users and license it under the GPL and make it available as free software. [1][2] Just from the top of my head. You're welcome internet, I saved you. [1] https://www.gnu.org/philosophy/javascript-trap [2] https://www.gnu.org/software/librejs/free-your-javascript