liveBook · Manning

What you will learn in Vanilla Web

Building apps without frameworks

by Maximiliano Firtman · Manning Early Access Program (MEAP)

Chapter by chapter

Chapter 1: Hello Vanilla Web

The introduction argues for choosing web tools based on project needs, explains the appeal of working directly with the browser, and distinguishes libraries from frameworks.

1.1 What Vanilla Web is not · 1.2 What Vanilla Web is · 1.3 How it works · 1.4 Remembering our goals · 1.5 Using Vanilla Web · 1.5.1 Mixing Vanilla with libraries · 1.6 Enhancing your skills · 1.7 Characteristics · 1.8 Challenges · 1.9 Summary

What you learn in chapter 1 →

Chapter 2: Understanding the web platform

The chapter introduction argues that the web platform is powerful by default, even though a focus on libraries and frameworks can obscure its advantages.

2.1 Building blocks · 2.1.1 Rendering engines · 2.1.2 Network protocols · 2.1.3 Web security · 2.1.4 Application architecture · 2.1.5 HTML, CSS, and JavaScript · 2.2 Design Patterns · 2.2.1 Web APIs · 2.3 The power of Vanilla Web · 2.3.1 Web performance · 2.3.2 Accessibility · 2.3.3 Distribution · 2.3.4 Discardability · 2.4 Modern web apps · 2.4.1 Installability · 2.4.2 Offline support · 2.4.3 Data Storage · 2.4.4 Internationalization · 2.4.5 Capabilities API · 2.4.6 Client-side AI · 2.5 Developer experience · 2.5.1 Simple and more secure organization · 2.5.2 Interoperability with libraries and frameworks · 2.5.3 Cost reduction · 2.5.4 Reduced Complexity Tax · 2.5.5 Deploying the apps · 2.6 Summary

What you learn in chapter 2 →

Chapter 3: The user interface

The chapter introduces a platform-first approach to UI and explains why Vanilla Web favors declarative HTML, CSS, and native controls.

3.1 Defining our user interface · 3.2 The ultimate responsive design · 3.3 Web metadata · 3.3.1 Title · 3.3.2 Web app manifest · 3.3.3 Icons · 3.3.4 Theme color · 3.3.5 Viewport definition · 3.3.6 Semantic metadata · 3.3.7 Putting the metadata together · 3.4 Semantic HTML · 3.4.1 Using the Right Element · 3.4.2 Avoiding divitis and other problems · 3.4.3 Semantic attributes · 3.5 Accessibility · 3.5.1 Landmarks · 3.5.2 Forms · 3.5.3 Keyboard Navigation · 3.5.4 ARIA Roles · 3.5.5 ARIA states and properties · 3.5.6 Color and contrast · 3.5.7 Interactive elements · 3.5.8 Screen readers · 3.6 Media resources · 3.6.1 Image formats · 3.6.2 Video formats · 3.6.3 AR formats · 3.7 Rich web UI controls · 3.7.1 Summaries · 3.7.2 Accordions · 3.7.3 Modal dialogs · 3.7.4 Carousels · 3.7.5 Popovers · 3.7.6 Rich selectors · 3.7.7 Other UI controls · 3.8 Beyond basic UI · 3.8.1 Using canvas · 3.8.2 Using UI-related APIs · 3.9 Summary

What you learn in chapter 3 →

Chapter 4: Vanilla CSS

The chapter introduces direct use of modern CSS for Vanilla Web apps and gives principles for keeping styles maintainable.

4.1 Maintainable and modular CSS · 4.1.1 Cascade Layers · 4.1.2 Custom properties (variables) · 4.1.3 Container queries and units · 4.1.4 Nested selectors · 4.1.5 New pseudo-selectors · 4.1.6 Modern CSS units · 4.2 Modern Layout · 4.2.1 1D layout with Flexbox · 4.2.2 2D layout with grids · 4.3 Animations · 4.3.1 Transitions · 4.3.2 Keyframe animations · 4.3.3 Page transitions · 4.3.4 Scroll-driven animations · 4.4 Summary

What you learn in chapter 4 →

Chapter 5: Vanilla JavaScript

Introduces Vanilla JavaScript’s role in web apps and explains why ECMAScript versioning matters when code is shipped without a framework build process.

5.1 Versioning · 5.2 Latest additions to the language · 5.2.1 ESNext · 5.3 Using a transpiler · 5.4 Using polyfills · 5.5 ECMAScript Modules · 5.5.1 Named exports · 5.5.2 Importing modules · 5.5.3 Import Maps · 5.5.4 Top-level await · 5.5.5 Preloading and execution order · 5.5.6 Lazy loading · 5.5.7 Error handling and timeouts for dynamic imports · 5.5.8 Import attributes and JSON modules · 5.5.9 Re-exports and module organization · 5.5.10 Caching, single evaluation, and side effects · 5.5.11 Practical rules of thumb · 5.6 Modern JavaScript Essentials · 5.6.1 Optional chaining and nullish coalescing · 5.6.2 Logical assignment operators · 5.6.3 Destructuring + rest/spread in practice · 5.6.4 Classes with public & private fields · 5.6.5 Cleaner errors: optional catch binding and error cause · 5.6.6 Small quality-of-life wins · 5.7 Collection Management · 5.7.1 Arrays · 5.7.2 Sets · 5.7.3 Maps · 5.7.4 Weak collections: memory-friendly · 5.8 Functional Programming · 5.8.1 Array transformations · 5.8.2 Pure functions and immutability · 5.8.3 Function composition · 5.8.4 Everyday benefits · 5.9 Error Management · 5.9.1 Exceptions and try/catch · 5.9.2 Error objects · 5.9.3 Asynchronous errors · 5.9.4 Global handlers · 5.9.5 Practical guidance for error management · 5.10 Summary

What you learn in chapter 5 →

Chapter 6: The document object model API

Introduces the DOM as the browser’s in-memory document tree and explains why native APIs and careful updates are enough to build interfaces without a library.

6.1 The DOM tree · 6.2 The API · 6.2.1 HTMLElement interface · 6.2.2 Global DOM objects · 6.2.3 Working with different documents · 6.2.4 Querying the document · 6.2.5 Browsing the tree · 6.2.6 Elements available · 6.2.7 Modifying elements · 6.2.8 Properties vs. attributes · 6.2.9 Creating elements · 6.2.10 Element arrangement · 6.2.11 Custom properties with dataset · 6.2.12 Working with styles · 6.2.13 Working with events · 6.3 Browser Web APIs · 6.4 Summary

What you learn in chapter 6 →

Chapter 7: Web components

Introduces web components as the chapter’s approach to building maintainable, reusable user interfaces and previews the topics ahead.

7.1 The component design pattern · 7.2 Use cases · 7.3 Advantages · 7.4 Challenges · 7.5 Vanilla web components · 7.5.1 Architecture · 7.5.2 The puzzle · 7.5.3 Abilities · 7.6 Custom Elements API · 7.6.1 Creation · 7.6.2 Rendering content · 7.6.3 Registration · 7.6.4 Simplifying the syntax · 7.6.5 The Custom Element Registry · 7.7 Our first component · 7.8 Shadow DOM · 7.8.1 Creation · 7.8.2 Styles with the page DOM · 7.8.3 Styles with Shadow DOM · 7.8.4 Styling web components · 7.9 Element parameterization · 7.9.1 data-* vs standard attributes · 7.9.2 Boolean attributes · 7.9.3 Update the component while observing attributes · 7.9.4 Update the component observing properties · 7.10 Creating a rating component · 7.11 Working with events · 7.12 Connecting the page DOM and shadow DOM with CSS · 7.12.1 Read custom properties for theming · 7.12.2 Expose custom properties for parametrization · 7.12.3 Expose elements to the page DOM · 7.12.4 Read state from the page DOM · 7.13 Summary

What you learn in chapter 7 →

Chapter 8: Working with templates and slots

The introduction explains why inline web-component markup may become less suitable as components and applications grow, then previews the chapter’s alternatives.

8.1 The Template Content HTML Element · 8.1.1 Usage · 8.1.2 The Need for Cloning Templates · 8.1.3 Advantages · 8.2 Using Templates in Web Components · 8.2.1 Defining a Template in the HTML document · 8.2.2 Using external HTML files · 8.2.3 Loading external CSS stylesheets · 8.3 Rendering Dynamic Data in Templates · 8.3.1 Creating a Custom Template Engine · 8.3.2 Using Community Template Engines · 8.4 Using Slots · 8.4.1 Fallback Content · 8.4.2 Full example · 8.4.3 The Flattened Tree · 8.4.4 Multiple Elements in One Slot · 8.5 Styling Slotted Content · 8.5.1 The ::slotted() pseudo-Element · 8.5.2 Styling Strategies · 8.6 Slots API · 8.6.1 The slotchange Event · 8.6.2 assignedNodes and assignedElements · 8.6.3 Practical Example: Tab Component · 8.6.4 Finding a Slot’s Assigned Slot · 8.7 Nested Slots · 8.8 Slot Best Practices · 8.9 Summary

What you learn in chapter 8 →

Chapter 9: Advanced web components

This introduction previews advanced web component topics aimed at making components more like native controls, easier to integrate, and simpler to ship.

9.1 Element internals · 9.1.1 Form participation · 9.1.2 Validation methods · 9.1.3 Accessing form and labels · 9.2 Web components lifecycle · 9.2.1 Basic lifecycle flow · 9.2.2 The adoptedCallback() in practice · 9.2.3 Form-associated lifecycle · 9.2.4 Restoring form state after navigation · 9.2.5 Cleanup in disconnectedCallback() · 9.2.6 Waiting for element registration · 9.2.7 Styling undefined elements with :defined · 9.3 Advanced accessibility for web components · 9.3.1 ARIA via ElementInternals · 9.3.2 Common ARIA properties · 9.3.3 Building an accessible toggle · 9.4 Focus and keyboard management · 9.4.1 Delegating focus into shadow DOM · 9.4.2 Managing focus programmatically · 9.4.3 Keyboard interaction patterns · 9.5 Custom state set · 9.5.1 The states property · 9.5.2 The :state() pseudo-class · 9.5.3 Building a stateful component · 9.6 Declarative Shadow DOM · 9.6.1 Basic syntax · 9.6.2 When to use Declarative Shadow DOM · 9.6.3 Hydrating a declarative shadow root · 9.6.4 Using CSS with DSD before hydration · 9.6.5 DSD configuration attributes · 9.6.6 Resource loading in declarative shadow roots · 9.7 Testing web components · 9.7.1 A simple browser-based test page · 9.7.2 Testing shadow DOM and slots · 9.7.3 Testing form-associated components · 9.7.4 Visual regression testing · 9.8 Library integration · 9.8.1 Using web components in frameworks · 9.8.2 Wrapping React components as web components · 9.8.3 Wrapping Angular components as web components · 9.8.4 Wrapping Vue components as web components · 9.9 Deploying web components · 9.9.1 Shipping a standalone ES module · 9.9.2 Publishing as an npm package · 9.9.3 Offering a CDN-friendly build · 9.9.4 Bundling and transpiling · 9.9.5 Distribution checklist · 9.10 Summary

What you learn in chapter 9 →

Chapter 10: Navigation

Introduces navigation as movement between views and routing as matching a URL to content, while explaining why SPA routing still depends on the browser and server.

10.1 Navigation and routing on the Web · 10.1.1 Discoverability, accessibility, and graceful degradation · 10.1.2 Native navigation · 10.1.3 Client-side router · 10.1.4 Navigation and routing definitions · 10.1.5 Friendly URLs · 10.1.6 Real URLs · 10.1.7 Real links · 10.1.8 URL parts · 10.1.9 Route · 10.1.10 Canonical route shapes · 10.1.11 Route state · 10.2 The server · 10.3 Navigation interception · 10.3.1 Navigation entry list · 10.3.2 The Navigation API · 10.3.3 Cancellation with event.signal · 10.3.4 Form submissions · 10.3.5 Observing completion · 10.3.6 History API fallback · 10.4 Route matching · 10.4.1 Simple matching · 10.4.2 Matching routes with URLPattern · 10.4.3 Testing the matcher · 10.5 Summary

What you learn in chapter 10 →

Chapter 11: Building a router

The chapter previews building a client-side router from matched routes, including rendering, browser-cue updates, and view transitions.

11.1 Rendering routes · 11.1.1 Outlet and master pages · 11.1.2 Using DOM APIs · 11.1.3 Title and metadata · 11.1.4 Active navigation and focus · 11.1.5 Scroll restoration · 11.1.6 Using web components · 11.1.7 Route guards · 11.1.8 Not found and route errors · 11.2 Navigating to new routes · 11.3 View transitions for route change · 11.3.1 View Transitions API · 11.3.2 Cross-document view transitions · 11.3.3 Motion and accessibility · 11.4 Building a tiny Vanilla router · 11.4.1 First pass: a function-based router · 11.4.2 Second pass: a class-based router · 11.4.3 Using the router for a tab view · 11.5 Building a web component-based router · 11.6 Summary

What you learn in chapter 11 →

Chapter 12: Working with data

The chapter introduces working with data in Vanilla Web by contrasting framework-packaged data features with solutions assembled from browser primitives.

12.1 Working with HTTP · 12.1.1 Basic usage · 12.1.2 Sending data · 12.1.3 Credentials and cookies · 12.1.4 Headers and response parsing · 12.1.5 AbortController and stale requests · 12.1.6 Request lifecycle · 12.1.7 Streaming responses · 12.1.8 Uploads, downloads, and progress · 12.2 Working with WebSockets · 12.3 Remote data and local caches · 12.4 Data persistence · 12.4.1 Where browser storage lives · 12.4.2 Choosing a storage API · 12.4.3 Quotas and persistence · 12.4.4 Web Storage · 12.4.5 IndexedDB · 12.4.6 Cache Storage · 12.4.7 File systems · 12.4.8 Debugging and maintenance · 12.5 Summary

What you learn in chapter 12 →

Chapter 13: Data binding and reactivity

The introduction frames data binding as keeping a Vanilla app’s interface synchronized with changing data in both directions, without a framework runtime.

13.1 Reactive thinking · 13.2 Data binding techniques · 13.2.1 Direct DOM binding · 13.2.2 Derived bindings · 13.2.3 A render function with queueMicrotask() · 13.2.4 Binding through data-* attributes · 13.2.5 Binding with template strings · 13.2.6 Binding with <template> · 13.2.7 EventTarget stores · 13.2.8 Proxy · 13.2.9 Signals through a micro-library · 13.2.10 Choosing a binding pattern · 13.3 State management · 13.3.1 Design patterns · 13.4 Data validation · 13.5 Summary

What you learn in chapter 13 →

Chapter 14: Beyond basics

This chapter introduction previews small libraries, performance techniques, offline support, and installability for Vanilla Web apps.

14.1 Micro-libraries · 14.1.1 Design patterns · 14.1.2 Why JavaScript fits micro-libraries · 14.1.3 Limitations · 14.1.4 Adoption checklist · 14.1.5 Creating a micro-library · 14.1.6 Architecture · 14.1.7 Integration · 14.1.8 Documentation · 14.1.9 Typing declarations · 14.1.10 Packaging · 14.2 Useful micro-libraries today · 14.3 Lit for components · 14.4 Wrec for components · 14.5 Static site generation · 14.5.1 Advantages · 14.5.2 Ideas and tools · 14.6 Lazy loading · 14.6.1 Advantages · 14.6.2 Best practices · 14.6.3 Importing dynamic modules · 14.7 Best practices for fast web apps · 14.7.1 Why performance is important · 14.7.2 Basic tips · 14.7.3 Loading resources · 14.7.4 Execution performance · 14.8 Adding offline support · 14.8.1 Intro to service workers · 14.8.2 Creating a basic service worker · 14.8.3 Registration · 14.8.4 Cache design patterns · 14.8.5 Serve design patterns · 14.8.6 Debugging · 14.9 Make your web app installable · 14.10 Summary

What you learn in chapter 14 →

Chapter 15: Building an app

Introduces Luma Books and outlines the static Vanilla Web app that the chapter builds.

15.1 Planning · 15.2 Setting up the project · 15.2.1 The document metadata · 15.3 Screens and app architecture · 15.4 Routing and navigation · 15.5 Loading and persisting data · 15.6 Web components · 15.7 Data flow and reactivity · 15.8 Making the app installable and offline-capable · 15.9 Testing and running · 15.10 Deployment notes · 15.11 Closing notes · 15.12 Summary

What you learn in chapter 15 →

Concepts explained in this book

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.