by Kilian Valkhof published on Dec 02, 2023
Welcome to my article about the Rule of Least Power. Before you get defensive, let me assure you, I don’t hate JavaScript. In fact, I love it. I also love CSS and JSX HTML. The reason I adore all three is the principle of least power.
This principle is fundamental in web development and it encourages us to choose the least powerful language suitable for a given purpose. When it comes to web development, this means favoring HTML over CSS, and CSS over JS. While JavaScript is extremely versatile and allows you to dictate how the browser should act, it can also be prone to failure and can exclude certain users from accessing your content. On the other hand, HTML and CSS, being declarative, allow the browser to choose the most efficient way to carry out instructions, resulting in a more performant and accessible experience for users.
Although you may feel that you need JS for many things, it’s worth noting that browser makers and specification writers have been migrating a lot of functionality to CSS and HTML in recent years. The web’s backward compatibility means that once you learn a solution, it becomes part of your toolbox and will continue to work for the foreseeable future. So, while I’ll showcase some examples in this article, the main takeaway is that assumptions about the necessity of JavaScript should be periodically revisited to potentially improve website performance.
So, let’s start with something we’ve all encountered at some point,

