The Tools Beyond This Book
Open a frontend job listing or a tutorial and you meet a wall of names this book never used: npm, Vite, TypeScript, Tailwind, ESLint and a dozen more. It can look as if everything you have learned is the wrong way to do it. It is not. Most of those tools solve problems that appear only when a project gets big, a team gets large or the code gets complicated, and knowing which problem each one solves turns the wall into a map.
Compare a home kitchen with a restaurant kitchen. The restaurant has a dishwasher the size of a car, a walk-in fridge and a machine that peels potatoes, because it cooks for hundreds of people every night. A home cook with the same machines would spend all day cleaning and servicing them. Both kitchens cook with the same heat, knives and ingredients; the machines are there for scale. Software has one advantage over kitchens: you can move from one to the other a piece at a time.
This page is a map, not a tutorial. Nothing here needs installing to finish the book.
What Are Node and npm?
Node.js, usually called Node, is JavaScript that runs outside the browser, directly on a computer or a server. It is the same language you learned in Chapters 6 and 7, without the page: no document, no buttons, but access to files and the network. Most of the tools on this page are themselves programs written in JavaScript that run on Node.
npm comes with Node. It is two things at once: a public registry holding millions of shared pieces of code, called packages, and a command that downloads them into your project. You type that command in a terminal, a window where you control the computer by typing instructions instead of clicking, which is one reason this book avoided it.
The benefit is obvious: someone has already written a date picker, a chart library or a map, and you can use it in minutes. The price is less obvious. Every package is code you did not write and have not read, and most packages depend on other packages, so installing one can bring in hundreds. Each of them needs updating, and occasionally one turns out to have a security hole or to have been tampered with. A project with no packages has none of those problems.
What Does a Bundler Do?
Chapter 7 split the site's JavaScript into modules, and the browser loaded each file separately. For a site with three or four modules that is fine. A large application can have thousands of modules, its own and its packages', and loading them one by one would be slow.
A bundler combines many files into a few, strips out code that is never used, and shrinks what remains. Vite, which calls itself a build tool and bundles your code when you build, is one of the most widely used today. It also runs a development server that updates the page the instant you save, much as Live Preview does, and it can translate the other tools on this page into plain HTML, CSS and JavaScript as it goes.
The cost is a build step: the files you write are no longer the files the browser receives. Before publishing you run the build, and what you upload is its output. That is a new thing to understand when something goes wrong, and it is worth paying only when a project has enough modules and packages to need it.
What Is TypeScript?
TypeScript is JavaScript with one addition: you can write down what type each value should be. You can say that a project's title is a string, or that a function takes a number. A checker then reads your code before it runs and points out every place where the types do not fit.
Remember Chapter 6's surprise, where a text "5" plus the number 1 gave "51" instead of 6? If a function is declared to take a number, TypeScript flags the line that passes it the text "5", while you are still typing, instead of leaving you to discover the wrong total in the browser. In a codebase of hundreds of files and many authors, catching that whole class of mistakes early is worth a great deal.
Browsers do not run TypeScript. Before the code reaches the page, a tool removes the type notes and leaves plain JavaScript, which is why TypeScript projects almost always have a build step. Everything this book taught about JavaScript still applies underneath.
What About CSS Tools?
Sass is a preprocessor: you write in a richer version of CSS, and a tool turns it into ordinary CSS. For years it supplied things CSS lacked, above all variables and rules nested inside other rules. CSS now has both, as custom properties since Chapter 3 and nesting as a standard feature, so much of the original reason for Sass has gone, though many existing projects still use it.
Tailwind is a different idea. Instead of writing your own class names such as project-card and styling them in a stylesheet, you put many small ready-made classes straight into the HTML, each doing one thing: one sets padding, another centres text, another sets a colour. A build step then produces only the CSS those classes need. Teams like it because they rarely have to leave the HTML or name anything; critics find the HTML long and the styling hard to change in one place. It is a trade, not an upgrade.
Which Helpers Are Useful Now?
Two tools earn their place in almost every project, including small ones. A formatter rewrites the layout of your code, its indentation, spacing and line breaks, in one consistent style every time you save, so you never argue with yourself or a colleague about it. Prettier is the most common. Its VS Code extension carries its own copy of Prettier, so it works without Node or npm.
A linter reads your code looking for likely mistakes rather than layout: a variable declared and never used, two equals signs where you meant three, a name misspelled. ESLint is the standard linter for JavaScript. Its VS Code extension needs ESLint itself installed through npm, so it belongs to the day you start using npm, and it pays for itself soon after.
| Tool | The problem it solves | When you need it |
|---|---|---|
| npm | reusing code other people wrote | when a package saves real work, and you accept keeping it updated |
| Vite | many modules and packages loading slowly | large projects, or any project that uses the tools below |
| TypeScript | type mistakes found only at run time | big codebases, many authors, code that lives for years |
| Sass / Tailwind | writing and organising a lot of CSS | large sites or teams; modern CSS covers much of it now |
| Prettier / ESLint | inconsistent layout and likely bugs | Prettier today; ESLint once you use npm |
- "Real developers always use a build step." Many real sites do not need one, including this book's. Add tools when a problem appears that they solve, not before.
- "TypeScript is a different language to learn from scratch." It is JavaScript plus type notes. Everything in this book still applies, and the notes can be learned a few at a time.
- "More tools make a better project." Each tool is something to install, configure, update and understand when it breaks. A tool that solves no problem you have is pure cost.
- You can now read a job listing or a project's setup and know what each part is for, instead of seeing a wall of names.
- It sets the order: learn the platform first, then the tools that sit on top of it. Every one of them outputs the HTML, CSS and JavaScript you already know.
Knowledge Check
A project has grown to hundreds of modules and packages that load slowly one by one. Which kind of tool addresses that?
- A formatter such as Prettier
- A linter such as ESLint
- A CSS framework such as Tailwind
- A bundler such as Vite
What does the browser actually run in a project written in TypeScript?
- The TypeScript files, read as they are
- Plain JavaScript made from the TypeScript
- A compiled program, like a desktop app
- HTML and CSS generated from the types
When does adding a build step usually earn its cost?
- When many modules, packages and people share a project
- As soon as the site has more than one HTML page
- Whenever a site is about to be published on the web for others
- Before writing the very first line of code in any new project
What is the main price of installing packages with npm?
- A licence fee for each package downloaded
- Your own code must then be written in TypeScript as well
- Code you did not write, which must be kept updated
- The site stops working without an internet link
You got correct