liveBook · Manning

Chapter 4: Building web applications

What you will learn in chapter 4 of Secrets of the JavaScript Ninja, Third Edition

The introduction explains how JavaScript became central to web development and why developers still need to understand browser behavior.

After this chapter you will be able to

Section by section

Introduction

The introduction explains how JavaScript became central to web development and why developers still need to understand browser behavior.

Key terms: JavaScript, HTML, CSS, components, browser

4.1 The lifecycle overview

This section outlines the client-side web application lifecycle and illustrates it with a page that records script and keyboard events.

Key terms: client-side web application, request, response, page building, event handling, GUI, event handlers, event list, appendToEventList, DOMContentLoaded

4.2 The page-building phase

The section explains how the browser builds a page’s DOM from HTML and how a script can interrupt that process.

Key terms: HTML document, Document Object Model (DOM), tree, <script> tag, parsing, DOM tree, async, defer, module

4.2.1 Parsing HTML and building the DOM

This section explains how the browser turns HTML into a DOM tree, including how it can correct invalid HTML while building that tree.

Key terms: page-building phase, HTML element, DOM, node, root html node, parent, children, siblings, HTML, blueprint

4.2.2 Executing JavaScript code

This section explains how a synchronous script interrupts page building, changes the DOM, and leaves global state available when HTML processing resumes.

Key terms: synchronous script node, page-building phase, DOM construction, event handling, document, querySelector, event-list, appendToEventList, li element, DOM nodes

4.3 Event handling

Introduces event handlers as the way client-side JavaScript makes web applications interactive.

Key terms: events, event listeners, handlers, page-building phase

4.3.1 Event-handling overview

This section explains how the browser queues and handles events one at a time, why slow handlers make pages unresponsive, and why event handling is asynchronous.

Key terms: single-threaded execution model, event queue, event-handler function, event handlers, unresponsive web applications, event-handling phases, asynchronous, browser events, network events, user events

4.3.2 Registering event handlers

Explains how event handlers are registered and why an event handler on the document can receive a keyboard event fired elsewhere.

Key terms: event handler, event-handler registration, addEventListener, DOM element, DOMContentLoaded, keydown, document, keyboard focus, bubbling

4.4 Writing interactive HTML with JSX

This section explains how JSX and React let developers describe interactive pages as component output, while showing how React updates the DOM and why JavaScript-rendered pages can be slower to display.

Key terms: JSX, JSX compiler, runtime library, _jsx, state, events array, component, tree of elements, DOM, virtual DOM

4.5 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 3: Working with Node.js and npm Chapter 5: First-class functions for the novice: definitions and arguments →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.