jlwagner.net

I went and wrote a book

"Never again!" I lied after writing my last book, Yet — being the lying liar I am — I wrote another one. This time around, it was for A Book Apart.

My propensity for lying to myself aside, Responsible JavaScript is the book I've wanted to write for some time. While I hope lots of people buy and read it, I don't harbor those hopes because technical books make the big bucks (they rarely do). My hope is that the book's message gains a foothold in the web development industry — or at least sticks in its craw long enough — that it gets web developers thinking about their reliance — or perhaps their overreliance — on JavaScript.

I wrote Responsible JavaScript because the web has a growing JavaScript problem. Year over year, we're shipping increasingly more of it. We do this in part because it's simpler for developers and more cost-effective for businesses to take the work that servers often did in the past and make the end user's device do it instead. This isn't a sustainable default, because JavaScript bytes are more expensive than any other kind.

An analysis of main thread time across 2 million Lighthouse audits stored in The HTTP Archive. From the 50th percentile and up, JavaScript tasks occupy considerably more CPU time than non-JavaScript tasks.
An analysis of main thread time across 2 million Lighthouse audits stored in The HTTP Archive. From the 50th percentile and up, JavaScript tasks occupy considerably more CPU time than non-JavaScript tasks.

And, like — look — there are situations where client-side rendering makes sense. Not every experience on the web needs to be a series of synchronous navigation requests. This is just an example, but Spotify wouldn't work as well if it were a multipage website.

But you know what doesn't need to be a client-rendered single page application?

There are more examples than this of where JavaScript-heavy architectures detract from the user experience. If someone needs to pay their credit card bill, buy groceries, or apply for government assistance, how does a client-rendered user experience expedite that task?

The answer is, it doesn't unless you have access to fast devices and fast internet. It only gets harder for those in remote areas who — just like everyone else — rely on the web to navigate through life.

That's why I wrote Responsible JavaScript. It's a hell of an opinionated book — one that I suspect won't hit the mark for some web developers — but I'm confident in its message and I think it's worth our collective reflection on how we do our work.

I hope Responsible JavaScript will give web developers something to chew on for some time. If you think you or your development team might find value in it, please consider buying it. If you do, I hope you like it.

Special thanks to Estelle Weyl for her incredible foreword for my book, as well as Katie Sylor-Miller for her editorial input on this post.