Part 1
Chapter 1: The Broken Promise-- The first time you tried to build a web application, you probably did what everyone does. You opened a text editor, wrote some HTML, added a sprinkle of CSS, and then—feeling bold—you wrote a few lines of JavaScript to make a button do something. It worked. You clicked, something changed, and you felt a small surge of power. You were a web developer.Then came the second feature. And the third. And the request to save data between sessions. And the bug where updating one part of the screen inexplicably broke something else. And suddenly, your clean little project became a tangled mess of DOM selectors, event listeners, and global variables whose interactions you could no longer predict.
You added a setTimeout to fix one issue, which created two more. You copied a Stack Overflow answer that used jQuery, even though you didn't really understand jQuery. Your code became what developers have a special word for: brittle.This chapter is not about frameworks. Not yet. This chapter is about understanding the problem that frameworks exist to solve. Because if you do not truly feel the pain of vanilla JavaScript at scale, you will never appreciate what modern frameworks give you—and worse, you will use them incorrectly, treating them as magic instead of understanding them as engineering solutions.The Vanilla ExperimentLet us build something together.
Not a framework application. Not a toy example with a single interaction. Let us build a real, if modest, interactive widget using only pure, vanilla JavaScript. No libraries. No frameworks. Just the DOM APIs that have existed in browsers for two decades.We will build a task manager. Not the full application that appears later in this book, but a simplified version: a list of tasks, a button to add a new task, a checkbox to mark a task complete, and a filter that shows All, Active, or Completed tasks. This is, by any reasonable standard, a simple feature. A junior developer should be able to build it in an hour.Open your editor. Create an index.html file.