liveBook · Manning

Chapter 14: Beyond basics

What you will learn in chapter 14 of Vanilla Web

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

After this chapter you will be able to

What it builds on

Section by section

Introduction

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

14.1 Micro-libraries

This section explains what micro-libraries contribute to Vanilla projects and how to distinguish a focused helper from a framework-shaped dependency.

Key terms: micro-library, narrow contract, primitives, glue code, Vanilla projects, single concern, framework-shaped dependency, larger runtime

14.1.1 Design patterns

This section identifies design traits that keep micro-libraries small, compatible with the web platform, and easy to remove from Vanilla projects.

Key terms: micro-library, platform objects, functions, modules, promises, events, standard HTML, CSS, and JavaScript, feature detection, progressive enhancement, fail gracefully

14.1.2 Why JavaScript fits micro-libraries

This section explains why JavaScript supports small, interoperable micro-libraries and warns against extending them by patching native prototypes.

Key terms: micro-libraries, ES modules, functions and closures, tagged template literals, interoperable contracts, small API surface, native prototypes, prototype patching, Array.prototype, HTMLElement.prototype

14.1.3 Limitations

This subsection explains why a micro-library’s small size does not guarantee that it is a good choice, identifying maintenance, architectural, and documentation costs.

Key terms: dependency fragmentation, micro-libraries, architectural drift, accidental coupling, framework lock-in, documentation, tiny API, abstraction, browser API, platform

14.1.4 Adoption checklist

This subsection frames micro-library adoption as a practical, explainable dependency decision rather than a test of minimalism.

Key terms: micro-library, dependency, architectural terms, kilobytes

14.1.5 Creating a micro-library

The section advises when to extract a micro-library and describes the shape that repeated real-world use helps produce.

Key terms: micro-library, entry point, input and output types, cleanup semantics, hidden globals

14.1.6 Architecture

This section shows how to extract a small store-and-render micro-library without taking over the rest of an app.

Key terms: store-and-render glue, state updates, subscriptions, batching, binding helper, scheduling, side effects, frameworks, rendering layers, README

14.1.7 Integration

This section explains how a micro-library can remain easy to integrate by working in different web contexts and using familiar browser API patterns.

Key terms: micro-library, integration points, browser-layer abstraction, cleanup functions, AbortSignal, cancellation

14.1.8 Documentation

This section explains what a micro-library README must say to help people adopt and safely use the library, including when code assistants use its documentation.

Key terms: micro-libraries, README, complete examples, API contract, side effects, return values, lifecycle rules, feature-detection requirements

14.1.9 Typing declarations

This section explains how a plain-JavaScript micro-library can provide useful type information without changing its runtime behavior or adding unnecessary complexity.

Key terms: TypeScript declaration file, .d.ts, public API, generic type T, generic type V, JSDoc, declaration files, package.json, JavaScript contract

14.1.10 Packaging

Explains how to package a Vanilla-oriented micro-library for portable use without imposing unnecessary build requirements.

Key terms: ES module, named exports, CDN, npm package, ESM entry point, bundler, build step, adoption cost

14.2 Useful micro-libraries today

This section frames community micro-libraries as ways to meet common Vanilla Web needs while building on browser primitives.

Key terms: micro-libraries, standards-first layers, Lit, browser primitives, application runtime

14.3 Lit for components

Explains how Lit reduces the work of authoring Web Components while preserving their standard custom-element contract, and when that trade-off is useful.

Key terms: Lit, custom elements, update cycle, template rendering, DOM events, reusable component layer, raw Custom Elements API, boilerplate, plain custom element, render function

14.4 Wrec for components

This section introduces Wrec as a way to author reactive web components while preserving the standard custom-element interface.

Key terms: Wrec class, reactive properties, scoped CSS, HTML template, expressions, standard custom elements, properties, attributes, DOM events, automatic property and attribute synchronization

14.5 Static site generation

This section explains how static site generation fits Vanilla Web and when creating HTML before deployment is a good choice.

Key terms: Static Site Generation, SSG, build step, static server, Vanilla Web, progressively enhance, static, dynamic

14.5.1 Advantages

This section explains how static site generation delivers useful HTML immediately, simplifies hosting, and lets Vanilla projects add interactivity only where needed.

Key terms: SSG, meaningful HTML, first response, operational complexity, CDN, server state, runtime dependencies, static generation, client-side behavior, content-first parts

14.5.2 Ideas and tools

This section explains how to choose a static site generator for a Vanilla frontend by judging the files it produces rather than the framework it uses.

Key terms: SSG, build script, Vanilla frontend, clean HTML, <head> metadata, ES modules, incremental builds, portable, standard files

14.6 Lazy loading

This section defines lazy loading as a performance strategy, identifies native tools for deferring work, and cautions against delaying what users need immediately.

Key terms: lazy loading, non-critical work, loading="lazy", decoding="async", content-visibility: auto, IntersectionObserver, dynamic import(), critical CSS, core navigation, first interaction

14.6.1 Advantages

This section explains how lazy loading improves startup speed, prioritizes visible content, and keeps optional features easier to maintain.

Key terms: lazy loading, startup cost, first render, interactivity, resource prioritization, module boundaries, dependencies, global startup path

14.6.2 Best practices

This section gives practical rules for lazy loading resources without delaying essential content, shifting the layout, or hiding failures from users.

Key terms: critical CSS, core navigation, preload, below the fold, width and height, stable boundaries, feature modules, lazy import, loading, error, and retry states

14.6.3 Importing dynamic modules

Explains where dynamic imports fit in lazy loading and how preloading can prepare an optional module without executing it at startup.

Key terms: static imports, dynamic imports, core path, optional paths, module boundary, loading boundary, preload hint, dynamic import, import(), startup path

14.7 Best practices for fast web apps

This section frames fast Vanilla Web apps as the result of decisions that respect browser work, without assuming that the absence of framework overhead guarantees performance.

Key terms: browser’s pipeline, layout, painting, compositing, hydration runtime, framework scheduler, virtual tree, main thread, budgets, measurement

14.7.1 Why performance is important

The section explains why web performance matters to users and which outcomes are worth measuring.

Key terms: performance, user experience, accessibility, product constraint, first route, JavaScript, Vanilla Web, meaningful content, layout shifts, first interaction

14.7.2 Basic tips

This section gives a practical baseline for making Vanilla Web apps fast through lean delivery, efficient DOM work, safe rendering, and realistic testing.

Key terms: semantic HTML, modular, ES modules, event delegation, listeners, DOM writes and reads, layout, state, render pass, textContent

14.7.3 Loading resources

The section explains how to keep resource loading from slowing a web app by shortening the critical path and prioritizing only resources needed soon.

Key terms: critical path, critical CSS, first paint, type="module", startup imports, responsive images, long-lived caching, fingerprinted assets, preload, modulepreload

14.7.4 Execution performance

This section identifies JavaScript execution patterns that hurt responsiveness and explains when to schedule work or move heavy tasks off the main thread.

Key terms: main thread, module evaluation, layout reads, layout writes, pagination, virtualization, queueMicrotask(), requestAnimationFrame(), requestIdleCallback(), Web Worker

14.8 Adding offline support

The section explains why offline support matters and introduces service workers as a way to handle requests when network access is unreliable.

Key terms: offline support, service worker, network proxy, Cache Storage, scope

14.8.1 Intro to service workers

Introduces what a service worker can do, why an app must not depend on it immediately, and the main stages of its lifecycle.

Key terms: service worker, controlled pages, DOM, Cache Storage, fetch, messaging, optional enhancement, first visit, core experience, Registration

14.8.2 Creating a basic service worker

Introduces a basic service worker that caches the app shell during installation, removes old caches during activation, and versions caches to prevent stale files.

Key terms: service worker, app shell, install, activate, cache name, activate handler

14.8.3 Registration

This section explains how to register a service worker and why its file location determines the pages it can control by default.

Key terms: service worker, register, support, scope

14.8.4 Cache design patterns

This section shows how to choose what remains available offline, where to store it, and how long different cached resources should remain valid.

Key terms: app shell, offline fallback page, Cache Storage, Request and Response pairs, IndexedDB, domain records, hashed filenames, HTML, API responses

14.8.5 Serve design patterns

This section explains how a service worker chooses a response strategy for each fetch request and why its choices should be conservative.

Key terms: fetch event, cache-first, versioned static assets, fetch API, network-first, offline.html, HTML, fetch handler, event.respondWith(), normal network request

14.8.6 Debugging

This section shows how to inspect and test service workers during development so an app’s offline behavior matches what it promises users.

Key terms: application tools, Application panel, Cache Storage, strategy decisions, first load, second load, offline load, update behavior, hard reload, browser-tab mode

14.9 Make your web app installable

This section explains what browser installability gives a web app and identifies the page metadata needed to begin making it installable.

Key terms: installability, standalone window, web APIs, Web App Manifest, icons, theme colors, page metadata

14.10 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 13: Data binding and reactivity Chapter 15: Building an app →

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.