Web, JavaScript and Bookmarklets

Yesterday she12 found a simple way to inject JavaScript into their theme on the Midnight Pub [1]. It's only a few lines, no dependencies. They randomly show an ASCII logo she12 created on each page load to those who have added the script to their theme. The pub doesn't have that script by default, but those who chose to add them can enhance the atmosphere without breaking it. It's purely aesthetic. The place works well without it. But with it, it's a little more fun. It's been a while since I haven't been so excited about a tiny bit of JavaScript.

Lately I decided to remove JavaScript from most of my projects. It's an added constraint that brings a ton of benefits like simplicity, maintainability, robusness, speed and much more. Without JavaScript there's no way (well, actually there's CSS...) to trick a behavior, to fake an element on a page. What you see is what you have. And what you have, if designed correctly, is much more portable. Chances are you can even run it on 20 year-old browsers and it would work. But I don't worry so much about 20 year-old browser. What's more important to me is browsers 20 years in the future. If we stick to a subset of HTML and CSS, then there's a good chance they would be able to support our site. I couldn't speak with so much confidence over an SPA written today. There are so many moving pieces.

So no JavaScript at all? Well, not necessarily. I'll still continue to ship my project without JavaScript, and I encourage you all to do it when possible. But to alter your own experience on a site, JavaScript can be great, just like she12 did on Midnight. People could decide if they want a JavaScript snippet to be added to the page or not. Those snippets can be shared through bookmarklets. We just click on them and they are installed on the site. Anyone could write those bookmarklets, including the site's creators themselves. The core site stays simple HTML+CSS, and the experience can be gradually improved in an opt-in way for anyone that wants to.

[1] Another Door


Written with Smol Pub
From Dusk's End, Nightfall City