2 Vanilla JavaScript—like in the old days
This chapter covers
- Building an application using vanilla JavaScript and HTML
- Creating DOM elements programmatically
- Using the Document API to manipulate the DOM
Before you can understand the benefits of using a frontend framework, you need to understand the problems that it solves, and there’s no better way to gain this understanding than to write an application without a framework. That is, you should do the framework’s job yourself. The objective of this chapter is to make you suffer the pain of writing applications without a framework so that you can build some appreciation for the job that frameworks do for you.
In the old days (I’m not that old, but technology evolves fast), developers wrote applications using only vanilla JavaScript and HTML. JQuery was the best we had; it provided a nice API to interact with the Document Object Model (DOM), hiding the browser differences. But we still had to write code down to the level of working with the DOM, and to be fair, the work wasn’t that bad. That is, it wasn’t bad until we used our first modern frontend framework (Angular, in my case). Now there’s no going back. We’ve been there. We know how much simpler it’s become to write JavaScript applications.