Browse all posts

Digging into JavaScript's `finally`: Completion Records, Flow Control Pitfalls, and the Road to `using`

Saw an interesting question pop up in a Discord server the other day that reminded me of a classic JavaScript head-scratcher: what really happens when you use flow control statements like return or throw inside a finally block? Most of us use try...catch...finally regularly, especially finally for crucial cleanup tasks: closing file handles, releasing network connections, resetting state, you name it. Its guarantee to run, whether the try block succeeds, fails (throw), or exits early (return), is fundamental. ...

September 8, 2023 · 7 min · 1409 words

Import Maps: The Missing Piece in JavaScript's Module Ecosystem

What are import maps? ES modules with direct URLs have been around for a while, allowing us to write code like: import { something } from 'https://cdn.example.com/packages/module/v1.2.3/index.js'; Import maps provide a level of indirection between module specifiers and the actual URL where the module resides. They’re a simple JSON structure that maps from import specifiers to URLs: <script type="importmap"> { "imports": { "react": "https://esm.sh/react@18.2.0", "react-dom": "https://esm.sh/react-dom@18.2.0", "lib/": "https://cdn.skypack.dev/lib@1.2.3/" } } </script> With this map in place, our application code can now use clean, maintainable imports: ...

May 18, 2023 · 5 min · 946 words

Qwik Preview: Rethinking JavaScript Hydration with Resumability

We’ve been wrestling with a performance paradox: we want to build rich, interactive web applications, but the process of getting them into the browser has become increasingly expensive. Hydration has slowly become one of our industry’s biggest performance bottlenecks. I recently spent a weekend exploring this experimental framework, and I’m genuinely intrigued by its approach. While it’s definitely not production-ready yet, Qwik represents a fundamental rethinking of how we deliver JavaScript to the browser. ...

October 3, 2022 · 6 min · 1207 words

ESM in the Wild: Field Notes from the JavaScript Module Transition

Libraries are shifting to ESM-only, build tools reveal sharp edges, and mixed ecosystems introduce subtle incompatibilities. This post offers a technically grounded snapshot of challenges and emerging patterns during this transitional phase, based on my hands-on experience and community input. How We Got Here JavaScript’s module story has been… complicated. In the early days, all JavaScript code lived in the global scope. Developers relied on naming conventions and immediately invoked function expressions (IIFEs) to prevent collisions. Then Node.js came along with CommonJS, giving us require() and module.exports. Finally, in 2015, ECMAScript 6 introduced native modules with import and export statements. ...

August 20, 2022 · 7 min · 1427 words

React 18's useId(): The End of Element ID Generation Headaches

I wasn’t expecting this post to be this long when writing it, but I think it reflects that it’s been a surprisingly thorny challenge of generating unique IDs for HTML elements in React. What looks trivial on the surface “just create a unique string” becomes a complex problem when you factor in (streaming) server-side rendering, (partial) hydration, and accessibility requirements. With React 18’s release, the team finally shipped an official solution: the useId() hook. ...

June 10, 2022 · 13 min · 2592 words