JavaScript

A recurring theme in my writing and talks is “lay off the JavaScript, people!” But I have to make a conscious effort to specify that I mean client-side JavaScript.

I thought it would be obvious from the context that I was talking about the copious amounts of JavaScript being shipped to end users to download, parse, and execute. But nothing’s ever really obvious. If I don’t explicitly say JavaScript in the browser, then someone inevitably thinks I’m having a go at JavaScript, the language.

I have absolutely nothing against JavaScript the language. Just like I have nothing against Python or Ruby or any other language that you might write with on your machine or your web server. But as soon as you deliver bytes over the wire, I start having opinions. It just so happens that JavaScript is the universal language for client-side coding so that’s why I call for restraint with JavaScript specifically.

There was a time when JavaScript only existed in web browsers. That changed with Node. Now it’s possible to write code for your web server and code for web browsers using the same language. Very handy!

But just because it’s the same language doesn’t mean you should treat it the same in both circumstance. As Remy puts it:

There are two JavaScripts.

One for the server - where you can go wild.

One for the client - that should be thoughtful and careful.

I was reading something recently that referred to Eleventy as a JavaScript library. It really brought me up short. I mean, on the one hand, yes, it’s a library of code and it’s written in JavaScript. It is absolutely technically correct to call it a JavaScript library.

But in my mind, a JavaScript library is something you ship to web browsers—jQuery, React, Vue, and so on. Whereas Eleventy executes its code in order to generate HTML and that’s what gets sent to end users. Conceptually, it’s like the opposite of a JavaScript library. Eleventy does its work before any user requests a URL—JavaScript libraries do their work after a user requests a URL.

To me it seems obvious that there should an entirely different mindset for writing code intended for a web browser. But nothing’s ever really obvious.

I remember when Node was getting really popular and npm came along as a way to manage all the bundles of code that people were assembling in their Node programmes. Makes total sense. But then I thought I heard about people using npm to do the same thing for client-side code. “That can’t be right!” I thought. I must’ve misunderstood. So I talked to someone from npm and explained how I must be misunderstanding something.

But it turned out that people really were treating client-side JavaScript no different than server-side JavaScript. People really were pulling in megabytes of other people’s code to ship to end users so that they could, I dunno, left pad numbers or something.

Listen, I don’t care what you get up to in the privacy of your own codebase. But don’t poison the well of the web with profligate client-side JavaScript.

Have you published a response to this? :

Responses

Paul Morriss

I agree w/ adactio.com/journal/19531 about too much javascript. I saw a tweet “what’s the most important thing to decide for a new web project?”. Answers were serious so I didn’t chip in, but I think it’s “deciding what animated icon to use while downloading all. that. javascript.”

Joseph Scott

“To me it seems obvious that there should an entirely different mindset for writing code intended for a web browser. But nothing’s ever really obvious.” — so much this, they share syntax, everything else should be considered different adactio.com/journal/19531

Tane Piper

@Aaron when we were building our game engine in 2001 we used Spidermonkey as the the scripting engine for missions.

# Posted by Tane Piper on Tuesday, November 22nd, 2022 at 7:45pm

ppk

@Aaron Netscape Something Server.

# Posted by ppk on Tuesday, November 22nd, 2022 at 8:01pm

1 Like

# Liked by Marty McGuire on Wednesday, October 19th, 2022 at 4:46pm

Related posts

Progressively enhancing maps

How I switched to high-resolution maps on The Session without degrading performance.

Responsibility

Fear of a third-party planet.

Schooltijd

Going back to school in Amsterdam.

Switching costs

The enshittification of React …which was already pretty shitty for users.

event.target.closest

DOM scripting and event handling.

Related links

I’m more proud of these 128 kilobytes than anything I’ve built since | by Mike Hall | Jul, 2025 | Medium

I don’t normally link to articles on Medium—I respect you too much—and I do wish this were written on Mike Hall’s own site, but this is just too good not to share.

And don’t dismiss this as a nostalgiac case study from the past:

At no point did the constraints make the product feel compromised. Users on modern devices got a smooth experience and instant feedback, while those on older devices got fast, reliable functionality. Users on feature phones got the same core experience without the bells and whistles.

The constraints forced us to solve problems in ways we wouldn’t have considered otherwise. Without those constraints, we could have just thrown bytes at the problem, but with them every feature had to justify itself. Core functionality had to work everywhere, and without JavaScript crutches proper markup became essential.

This experience changed how I approach design problems. Constraints aren’t a straitjacket, keeping us from doing our best work; they are the foundation that makes innovation possible. When you have to work within severe limitations, you find elegant solutions that scale beyond those limitations.

Tagged with

Close to the metal: web design and the browser

It seems like the misguided perception of needing to use complex tools and frameworks to build a website comes from a thinking that web browsers are inherently limited. When, in fact, browsers have evolved to a tremendous degree

Tagged with

Who’s Afraid of a Hard Page Load?

Why single-page apps are just not worth it:

Here’s the problem: your team almost certainly doesn’t have what it takes to out-engineer the browser. The browser will continuously improve the experience of plain HTML, at no cost to you, using a rendering engine that is orders of magnitude more efficient than JavaScript.

Meanwhile, the browser marches on, improving the UX of every website that uses basic HTML semantics. For instance: browsers often don’t repaint full pages anymore.

Tagged with

MomBoard: E-ink display for a parent with amnesia

Technology doesn’t have to be terrible. Here’s an absolutely wonderful use of an e-ink display:

I made as much use of vanilla HTML and CSS as possible. I used a small amount of JavaScript but no framework or other libraries.

Tagged with

The State of ES5 on the Web

This is grim:

If you look at the data below on how popular websites today are actually transpiling and deploying their code to production, it turns out that most sites on the internet ship code that is transpiled to ES5, yet still doesn’t work in IE 11—meaning the transpiler and polyfill bloat is being downloaded by 100% of their users, but benefiting none of them.

Tagged with

Previously on this day

5 years ago I wrote Continuous partial browser support

Treat every browser feature like an experimental feature.

17 years ago I wrote Announcing Huffduffer

I maded you a website.

20 years ago I wrote Back from Brussels

I spent the weekend in Brussels attending the Euro IA summit… well, kind of.

21 years ago I wrote Ch-ch-ch-changes

I’ve been doing some spring cleaning around here (if you’re reading this in an RSS reader, you might want to visit the site to investigate some of the changes).

22 years ago I wrote Elite

Yesterday’s magazine section of The Guardian included an extract from a forthcoming book entitled "Backroom Boys: The Secret Return of the British Boffin" by Francis Spufford.

24 years ago I wrote The Nobel Prize in Physics 2001

I was in the post office a few days ago to get a stamp. I needed to send a card to the States which costs 65p.