Read JavaScript and TypeScript lessons from production

Learning from tutorials is great! You follow some steps, learn a smol lesson, and feel like you got this. Then you go into an interview, get a question from the boss, or encounter a new situation and o-oh.

Shit, how does this work again? ๐Ÿ˜…

That's the problem with tutorials. They're not how the world works. Real software is a mess. A best-effort pile of duct tape and chewing gum. You need deep understanding, not recipes.

I took a bet on JavaScript in 2005 when it was known as DHTML. It's been my favorite language ever since. These essays are the good stuff you can't learn from a tutorial.

Leave your email and get the JavaScript Essays series - a series of curated essays and experiments on modern JavaScript. Lessons and insights learned from practice building production software.

Latest JavaScript articles from Swizec

January 2026

A better way to end-to-end test your webapp

End-to-end tests are the best way to test your webapp, but they're flaky and annoying to write. I'm trying a new agentic approach that fixes the issue.

September 2025

You may be looking for a useSyncExternalStore

When you see a `useEffect` that updates a `useState` and returns a value, you might be looking for a `useSyncExternalStore`. This is my current vendetta.

November 2024

The anatomy of a React Island

A coworker asked how React Islands work and I realized it's a technique I've been using to modernize monolithic web codebases for years, but never wrote down how it works.

November 2023

The efficacy of TypeScript

TypeScript may streamline code navigation and catch semantic errors, but it doesn't guarantee fewer bugs or faster fixes.

October 2023

TypeScript runtime vs types at run-time

Understanding the nuances of TypeScript: it adds static types to JavaScript, reducing bugs by checking code validity pre-run. But imagine if we had types at run-time too - validating inputs, enhancing error messages. A dream, but a nice one.

Bun โ€“ first impressions

I've been using Bun in a few side-projects and I like it a lot

July 2023

Update state during render, better explained

A few readers wrote in to say that the React Can Update State During Render email last week made no sense. Here's a better explanation.

June 2023

React can update state during render

An unexpected feature of React: updating state during render. It's a UX and performance optimization

January 2023

My biggest React App performance boost was a backend change

Performance lives in the unlikliest of places. Follow the metrics.

October 2022

Over-engineering tweet embeds with web components for fun and privacy

A way to embed tweets in static sites with full pre-renders and live updates using just 9kB of client-side JavaScript, 2 HTTP requests, and full reader privacy โœŒ๏ธ

April 2022

Quick tip about JavaScript's optional chaining operator

People on twitter loved this trick I learned from a coworker's pull request the other day. You might like it too.

Promise.allSettled, a wonderful tool for resilient code

The pros and cons of different approaches to writing resilient code that handles partial failures

February 2022

Immutability isn't free

Or how we took an API endpoint from 16s to 3s.

January 2022

Using DynamoDB Streams with the Serverless Framework

DynamoDB Streams are a convenient way to react to changes in your database. And surprisingly easy to use ๐Ÿฅณ

December 2021

pg-mem and jest for smooth integration testing

The cult of TDD leads you down a dark and stormy path towards brittle code with a false sense of security. But there is a better way. A sweet spot between unit and heavy integration.

Why null checks are bad

Every null or undefined check doubles the number of tests you need ๐Ÿ˜ฑ

Small choices can wreck your codebase

wanna see the strangest looping construct I've found in production code?

November 2021

Finding unresolved promises in JavaScript

JavaScript is a fantastic server-side language because it's async. That also makes it tricky. ๐Ÿ’ฉ What happens when you swallow errors? Forget to resolve promises? Or run into a number of other anti-patterns

October 2021

How to configure Jest with TypeScript

Using plain Jest on a TypeScript codebase is kinda rough. No types in tests no thanks. Making Jest and TypeScript work together smoothly is something you do just rarely enough to forget the details. Hope this helps you and future me too โœŒ๏ธ

Learn TypeScript in 5 minutes

TypeScript solves many of JavaScript's sharpest edges. You don't need much to get started โœŒ๏ธ

September 2021

Stop SHOUTING = 'shouting'

A hill I will die on ๐Ÿ‘‰ global CONSTANT = 'constant' are bad

June 2021

A surprising feature of JavaScript optional chaining

This blew my mind, thought you'd like it too. You can do more with ?. than you thought.

April 2021

2 quick tips for 250% better Lighthouse scores โ€“ CodeWithSwiz 28

Your site may be fast for users, but Google don't care. Official metrics or bust.

February 2021

A TypeScript trick for reusable hooks

Reusable hooks are all fun and games until TypeScript starts yelling at you about incompatible types.

September 2020

Modern backend is a JavaScript function

Many engineers think server-side code is the scary domain of True Engineers. Something newbies, juniors, and frontend engineers shouldn't touch. They're wrong. Modern backend is a joy. โค๏ธ

August 2020

In 2020's, what is "frontend"? ๐Ÿคจ

"He's a frontend guy, is this even a fair question to ask?" The head of engineering was worried about our systems design question โ€ฆ

August 2019

The Big Mac index and Jest fetch testing

The Big Mac index is a purchasing power parity index published by The Economist. Jest fetch testing is a tech task so frustrating that it almost made me quit the industry. I'm writing this so you don't have to read 8234721 different blog posts, stack overflow answers, and GitHub threads with conflicting info on how to get Jest and fetch to play together.

May 2019

Just for fun ๐Ÿ‘‰ React vs. jQuery vs. Svelte, same ๐Ÿฑ app

I was bored Monday night and decided to see if I still know how to build with jQuery. Nothing better to do, no pressing ideas, a bit of fun. Also a favor for a friend who's preparing to talk about React to a bunch of people who've never seen it before ๐Ÿ˜›

LOLCODE-to-JavaScript compiler babel macro

A fully functioning LOLCODE-to-JavaScript compiler implemented as a Babel macro. You never thought you wanted this and now here it is. You're welcome. ๐Ÿฑ

February 2018

Building an interactive DOM benchmark, preliminary results