Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Joe Attardi

Rating 3.5 AI initial rating

JavaScript gives web developers great power to create rich interactive browser experiences, and much of that power is provided by the browser itself. Modern web APIs enable web-based applications to come to life like never before, supporting actions that once required browser plug-ins. Some are still in an experimental stage, but many are ready for use today. With this hands-on cookbook, author Joe Attardi helps you explore the powerful APIs available in modern browsers and guides you through the specific tasks that they unlock. Because these features are web standards, there is comprehensive documentation available from trusted resources such as MDN Web Docs. The knowledge you'll gain is transferable across different companies and projects. Learn the breadth of functionality available in modern browser APIs Explore future APIs that are still in an experimental stage Discover newer elements, such as dialog that replaces the need for a third-party library Build more powerful and interactive web applications using native APIs Understand the permissions model used by the browser to unlock functionality such as geolocation and push notifications

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A task-driven tour of the browser's built-in JavaScript APIs, showing you how to replace third-party libraries and plug-ins with native web standards. Best for intermediate JavaScript developers who want to build richer, more interactive web apps without adding dependencies. 【Book Arc】 - **Opening (~0%–10%)**: Frames the shift from plug-in-era browsers to modern standards-based APIs, explains what a web API is, and weighs polyfills against native support. - **Early (~10%–32%)**: Covers foundational browser capabilities — image loading with fallbacks, Promise coordination (`all` vs. `allSettled`), `requestAnimationFrame` animation, local storage persistence with JSON serialization, and client-side routing via the History API. - **Middle (~32%–50%)**: Moves into network communication (XHR, Fetch, file uploads, beacons, server-sent events, WebSockets) and client-side data storage with IndexedDB transactions, cursors, and pagination. - **Late (~50%–75%)**: Shifts to DOM observation with `IntersectionObserver` — lazy loading, auto-pausing video, scroll-triggered transitions — plus newer native elements like `dialog`. - **Ending (~75%–100%)**: Addresses the browser permissions model that gates powerful features such as geolocation and push notifications, and touches on experimental APIs not yet universally supported. 【Key Takeaways】 - **Modern browsers replace plug-ins and libraries** (Opening): Native APIs now handle what once required Flash, ActiveX, or third-party packages — reducing bundle size and maintenance risk. - **Polyfills are a trade-off, not a free lunch** (Opening): They add bundle weight, may be unmaintained, and can't replicate advanced functionality performantly. - **Promise coordination matters** (Early): `Promise.all` fails fast and discards other results; `Promise.allSettled` always fulfills, letting you inspect each outcome — a key distinction for resilient async code. - **Client-side routing is achievable natively** (Early): `history.pushState` plus `popstate` handling and click interception builds a router without a framework, though you must handle the Back button explicitly. - **Fetch is the modern standard for network requests** (Middle): It supersedes the painful XHR API, and specialized tools — beacons for analytics, SSE for one-way streams, WebSockets for bidirectional real-time — cover distinct communication needs. - **IndexedDB is transactional and asynchronous** (Middle): Every read/write requires a transaction; operations return request objects that fire success events, and cursors enable pattern searches and pagination. - **IntersectionObserver unlocks viewport-aware UX** (Late): Lazy loading, auto-pause/play video, and scroll-triggered fade-ins all become straightforward with a single observer pattern. - **Permissions gate powerful features** (Ending): Geolocation, push notifications, and similar capabilities require understanding the browser's permission model before you can use them. 【Reading Tips】 - Treat this as a **cookbook, not a novel** — jump to recipes matching your current task rather than reading linearly. - **Deep-read the network and IndexedDB chapters** (Middle); these have the most conceptual density around async patterns and transactions. - **Skim the Preface and licensing material** (Opening) — it's boilerplate; get to the recipes quickly. - When a recipe references an experimental API, **check MDN for current browser support** before committing to it in production. - Take away the **patterns** (Promise wrapping, observer callbacks, transaction flow), not just the copy-paste snippets. 【Coverage Limits】 The excerpts cover the book's structure, early chapters, and select middle/late recipes, but do not detail the full permissions chapter or the specific experimental APIs discussed near the end. Some chapter contents are only visible via table-of-contents entries.
Page 6
44 4.2 Sending a GET Request with the Fetch API 45 4.3 Sending a POST Request with the Fetch API 46 4.4 Uploading a File with the Fetch API 48 4.5 Sending a...
View in text
Page 20
cts with an error if neither the image nor the fallback can be loaded (see Example 1-2). Example 1-2. Loading an image with a fallback * Loads an image. If t...
View in text
Excerpt 3
then click the browser’s Back button, nothing happens. This is because the page isn’t actually navigating, but just popping the previous state from the route...
View in text
Excerpt 4
can access the current item and/or move on to the next item. You can check if the contact name includes the query text and collect the results in an array (s...
View in text
Excerpt 5
set to true. This attribute is added when validation fails during form submission, or when an element loses focus. This prevents validation errors from appea...
View in text
Excerpt 6
promise; // The Promise is done. Now fade the loader out. // Don't stop the spin animation until the fade out is complete. 120 | Chapter 8: The Web Animation...
View in text
Excerpt 7
mat. It has a format method that you call with a value off‐ set, such as –2 (in the past) or 3 (in the future), and a unit such as “day,” “month,” etc. For e...
View in text
Excerpt 8
to the component’s slots can be styled by global CSS rules. The slotted content does not move into the shadow DOM, but rather remains in the standard, or lig...
View in text
Tags
AI categories
JavaScriptWeb TechnologyProgramming
ISBN: 1098150694
Publisher: O'Reilly Media
Publish Year: 2024
Language: English
Pages: 286
File Format: PDF
File Size: 3.3 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…