Posts

Showing posts with the label JavaScript

pnpm: One Copy of Every Package, Shared Across Projects

Image
Picture a laptop that has hosted a dozen JavaScript projects. The same version of Express sits in a dozen node_modules folders. It works, and on a fast connection nobody notices, until the disk fills up or a CI runner installs everything from scratch on every push. The waste is not dramatic, it is steady: a few minutes here, a few gigabytes there, and a node_modules folder that becomes the biggest thing on the machine. pnpm goes after that waste. It keeps one copy of each package version in a shared store and links it into every project that asks for it. Is that saving worth changing how installs work? Quick answer Yes, pnpm is worth it when several JavaScript projects share the same packages. It keeps one copy of each package version in a shared store and links it into every project, so installs are faster and use less disk space. Its strict node_modules layout also exposes packages the code uses but never declared, which keeps dependency lists honest. What I would check before u...

esbuild: Bundle JavaScript in Milliseconds, Not Seconds

Image
You change one line in a small project, save, and wait. The bundler thinks, the terminal scrolls, and a few seconds pass before the page refreshes. Do that forty times in an afternoon and you have lost several minutes to staring at a spinner, plus the focus you lose every time the flow breaks. Most bundlers are slow because they are written in JavaScript and parse everything with a JavaScript parser. For the language underneath the bundler, see JavaScript Explained: The Language That Runs the Whole Web . esbuild is written in Go, parses in parallel, and treats bundling as a compile step rather than a scripting task. The question is whether that speed is worth changing tools for, and what you give up in return. Quick answer Yes, esbuild is worth switching to when the build is slow enough to notice, because it bundles the shop calculator in 4 milliseconds instead of seconds. It is written in Go and parses in parallel, so two files become one 1.5kb bundle that prints the same receipt as...

React Router: Pages That Change Without Reloading

Image
Open a shop site and click a product. The address bar changes, the page changes, and nothing reloads. Visitors expect that smooth switch now, and it is what makes a single-page app feel finished rather than half built. Without a router, the usual workaround is a pile of state: a variable holding the current view, a switch statement rendering one component or another, and links that are really buttons wearing a disguise. It works for two pages, then starts to creak. The address bar never changes, so a visitor cannot bookmark a product, share its link, or use the back button properly. React Router closes exactly that gap, and the question is when it is worth adding. Quick answer Yes, React Router is worth adding when an app has three or more distinct views that people share links to. It maps each URL to a component, so /products shows the list and /products/2 shows the ceramic mug, and the address bar, back button, and bookmarks all keep working because Link renders as an ordinary anch...

Fastify: A Fast Node API Without the Ceremony

Picture a small shop that takes orders through a web page. A customer fills in a form, the browser sends the order as JSON, and a Node server has to check the fields, save the order, and answer with the new order id. For the language underneath Node, see JavaScript Explained: The Language That Runs the Whole Web . The work itself is small. The ceremony around it is not: parsing the body, checking that every required field is present, sending back the right status code when something is missing, and keeping the routes readable as they grow. Express leaves most of that to you, which is fine until the third route starts looking like the first two. That gap is where Fastify earns a look. Quick answer Yes, Fastify is worth using for a JSON API with several endpoints when you want validation and structure built in, because a JSON schema rejects bad requests before your handler runs and the client gets a clear 400 instead of a crash later. Handlers stay short by returning values instead of ...

Zustand: React State Without the Boilerplate

Picture a small shop page with a cart icon in the corner. A visitor adds a tote bag and a mug. Three parts of the page need to know what happened: the cart icon showing the count, the cart drawer listing the items, and the checkout button showing the total. If each part keeps its own copy of the cart, the numbers drift apart. The usual fix is to lift the state up to a shared parent, but that turns every middle component into a courier for data it never uses. That is the problem Zustand sets out to solve, and the question is whether a tiny store does the job better than the tools React already ships with. Quick answer Yes, Zustand is worth using when several distant components share state that changes a lot, because a tiny store holds the cart once and every part reads from it. Each component picks just the slice it needs, so the cart icon re-renders on a count change and ignores a price edit, and the total is computed from the items so it can never drift out of sync. Skip it when the...

Axios: HTTP Requests Without the Fetch Boilerplate

Picture a small shop dashboard, the kind of page that lists recent orders and lets you click into one. The fetch calls work, but every one of them looks the same: check response.ok, call response.json(), wrap the whole thing in try and catch, then repeat the pattern for the next endpoint. Three endpoints, three copies of the same ceremony, and the actual work, showing an order, stays buried underneath. That repetition is the whole question behind Axios. It does not add a new kind of request. It removes the repeated setup around requests you already make, and the question is whether that saving is worth a dependency. For the language underneath the requests, see JavaScript Explained: The Language That Runs the Whole Web . Quick answer Yes, Axios is worth adding when a page makes several requests with shared headers, an auth token, and a base URL, because one shared client holds that setup in one spot and each call becomes a single line. The data arrives already parsed, so list.data is...

TanStack Query: Fresh Server State, Less Boilerplate

Two visitors open the same bookshop page a minute apart. The first one buys the last copy of a title. The second visitor's page still says one copy is in stock, because the data was fetched once at load and never checked again. She clicks buy, and the order fails at checkout. That gap is the problem TanStack Query is built for. Data from a server is not like the state inside your app. It lives somewhere else, it changes without telling you, it can fail to arrive, and a copy fetched five minutes ago may be wrong. TanStack Query keeps a cache of that server data, refetches it when it goes stale, and retries when a request fails. For the language underneath the library, see JavaScript Explained: The Language That Runs the Whole Web . Quick answer Yes, TanStack Query is worth learning when two parts of an app need the same server data, or one screen needs that data to stay fresh, because it keeps a cache of the server data, refetches it when it goes stale, and retries when a request...

Biome: One Tool to Lint and Format Your JavaScript

A small shop's checkout script starts as twenty lines in one file, then three developers edit it. One prefers single quotes, another double quotes. One writes two-space indents, another tabs, and a third leaves a half-finished discount variable behind after a refactor. Nothing is broken: the script runs and the totals are right. But every pull request now carries an argument about style, and real problems, like that unused variable, hide in the noise. Two tools usually police this: a linter for mistakes and a formatter for style, each with its own config. Biome folds both jobs into one binary, and this post puts that claim to the test on a real file. For the language underneath the tool, see JavaScript Explained: The Language That Runs the Whole Web . Quick answer Yes, Biome is worth trying once more than one person touches the JavaScript, because one binary holds both the linter and the formatter, so there is one install, one config, and the two never fight each other. On a rea...