That HTML Blog logo

That HTML Blog

Subscribe
Archives
February 23, 2024

That HTML Blog #16: Scaling up imperative DOM APIs, utility-first CSS fails, safe DSD

Friday, February 23, 2024

Web development news seemed sluggish earlier this month (plus I spent the better part of February very sick!), but now I'm seeing things picking up again—not the least of which is that Firefox 123 is out which finally offers native support for Declarative Shadow DOM (DSD)! Now we can state with confidence that all modern browsers support DSD, and the days of reaching for a polyfill are numbered. 🎉

There's also been a ton of content and conversation floating about concerning the "future of the Jamstack" (including an upcoming interview I participated in which was very enjoyable), so we'll likely touch on that in a big way come March. For folks like me who've always felt the real promise of Jamstack approaches to web development was the intentional focus on static-first, HTML-first solutions, that should fit right in at That HTML Blog.

’Till next time,
Jared


The DX Limitations of Imperative APIs ➦​

In this essay at Smashing Magazine, Frederik Dohr walks through some of the challenges of scaling up purely “imperative” DOM APIs inside a web component to handle complex UI state and rendering. Now I happen to think there can be a wide spectrum of approaches and third-party solutions here. Imagine vanilla JavaScript all the way on one end of the spectrum, and React all the way on the other end of the spectrum. There’s a lot of room in the middle for light-weight tools which can address low-hanging fruit.

​Read on the web…​

​


​

Utility-First CSS Does a Disservice to Utilities ➦​

In this addition to the corpus of critiques of “utility-first” CSS, Heydon Pickering does an excellent job of explaining the strange world we find ourselves in where the C of CSS is simply being thrown away for the sake of a convenience that doesn’t actually end up very convenient at all in the long run.

​Read on the web...​


Variable Font Face Made Easy ➦​

I’ve set up @font-face rules and styling for variable fonts in the past, but I recall dealing with some fiddly bits that sort of turned me off from reaching for variable fonts as a default approach.

Well, in this example of how Michelle Barker got things set up for her site in a recent redesign, it seems very straightforward and makes a lot of sense.

​Read on the web…​


Practice Safe DSD with setHTMLUnsafe (It’s Complicated 😂) ➦​

All right, so you got your web server emitting some HTML with declarative shadow DOM (DSD). Great! You fetch a fragment of this HTML, and use innerHTML to set an element to display this new HTML.

Uh oh.

No worries, you think to yourself. You’ll use DOMParser.parseFromString to construct a new fragment from the server-provided string, and then append that to your page. Surely that will work!

Uh oh.

Yes, I’m sorry be the bearer of bad news, but the typical DOM APIs you use to turn strings of HTML into new DOM do not parse DSD. All those <template shadowrootmode="…"> tags remain just that, template tags. No shadow DOM to be found anywhere.

Until now.

​Read on the web…​


That HTML Blog​
Made with ❤️ in Portland, Oregon

See also our sibling publication The Spicy Web + Discord​
Follow The Spicy Web on Mastodon!

​

​

Don't miss what's next. Subscribe to That HTML Blog:
The Spicy Web That HTML Blog
Powered by Buttondown, the easiest way to start and grow your newsletter.