The Composer's First Unmeasured Prelude: On the Unchained Tempo of a Perfectly Asynchronous Script

In the early 18th century, a quiet revolution unfolded not on a battlefield, but on manuscript paper. French composers like Louis Couperin began crafting "unmeasured preludes"—pieces of music that abandoned the rigid grid of time signatures and bar lines. The notes were written, but their duration and rhythm were left entirely to the interpretation and skill of the performer. The score was a map of potential, not a set of strict instructions. The goal was a more fluid, expressive, and ultimately human performance, unshackled from the metronome’s tyranny.

This historical pivot mirrors a fundamental tension in our own craft: the battle between a perfectly measured, synchronous page load and the liberating, yet perilous, embrace of asynchrony. We are the composers of the web, and the `async` and `defer` attributes are our unmeasured preludes. They are instructions to the browser to break free from the strict, sequential score of the parser-blocking script. They promise a faster, more responsive experience, a page that can begin its render without waiting for every last instruction to be fetched and executed.

But like a harpsichordist faced with an unmeasured prelude, the browser is suddenly tasked with a profound responsibility. Without the guiding structure of the document order, it must interpret this new, unchained tempo. When we mark a script as `async`, we grant it a dangerous freedom. It will execute as soon as it is downloaded, regardless of where it appears in the document or its dependencies. The potential for a cacophonous race condition is high—a script that manipulates the DOM firing before the DOM is ready, or a vital library loading after the script that depends on it.

The `defer` attribute imposes a gentler structure, like a performer who agrees to play the notes in order but with a fluid sense of timing. These scripts are downloaded in the background but are executed strictly in order, after the parsing is complete. It’s a more predictable cadence, but it still requires the composer—the developer—to have a deep understanding of the dependencies and the desired outcome.

Couperin’s innovation demanded a supreme musician, one who could hold the entire composition in their head and make moment-to-moment decisions that served the music’s emotional core. Our modern unmeasured preludes demand no less. They are not a shortcut for the careless, but a powerful tool for the thoughtful. Using them well requires an intimate knowledge of our own score—the critical rendering path, the dependency graph, the user's journey. We must compose not just for speed, but for stability; not just for a metric, but for a harmonious, predictable experience. The ultimate performance depends on it.

Notes & further reading

A few pages I came back to while writing this: