Global Mutable State
One of the most confusing things I find with web development (which I&#x27;m mostly new to, coming from a backend background) is that everyone seems entirely happy with JS (or more accurately the DOM?) and CSS being giant mutable state buckets.<p>I&#x27;ve worked in mostly backend software for a decade, and web dev is easily the hardest thing I&#x27;ve ever had to work on.<p>CSS especially is a nightmare. It&#x27;s near impossible in complex projects to work out if your change is going to change other things adversely. Not only do you have to know all usages of the CSS class (for example), but if it&#x27;s a scoped class (.foo .bar) you have to know all instances in which is it scoped in this exact way. Because it&#x27;s visual you&#x27;re basically testing with your eyes, there is no &quot;refactor to green&quot; possible.<p>In Javascript it seems normal to (at least in angular) push to global scope, and so it can be really unclear where values come from, or how they get set.<p>I once tried to work out why a fancy ajaxed select box (rendered in JS &#x2F; CSS, naturally) was firing its onblur event at the wrong time. There were <i>at least</i> three JS event handlers (from memory, jquery, angular and native) that could possibly have events against it. Everything is smushed together, and because it&#x27;s about losing or gaining focus the observer effect comes into play, and… it&#x27;s a nightmare. From memory I just gave up, and I presume that particular bug still exists today.<p>Testing any of this stuff is also pretty nightmarish. Knowing the web I&#x27;m almost certainly behind the curve and there is new hotness out to solve this, but I&#x27;ve never much luck with automated browser testing. Things like Protractor tests are incredibly onerous to write, and inevitably end up as flakey slow messes that fail builds due to flake more often than they find issues.<p>I imagine there are lots of ways to solve these sorts of things, but all I&#x27;ve read feel like variants and retellings of &quot;do it right&quot;, which isn&#x27;t really that helpful, because a) what is right?, and b) it&#x27;s easy to slowly slip  away from &quot;right&quot; without noticing.