Table of Contents
Web API Cookbook Preface
Return to Web API Cookbook, Web APIs, Web API Bibliography, Web API DevOps
”JavaScript has come a long way since its introduction in late 1995. In the early days, the core APIs built into web browsers were limited. More advanced functionality typically required third-party JavaScript libraries, or in some cases even browser plug-ins.“ (WbAPICook 2024)
“A web API is a series of global objects and functions exposed by the browser. Your JavaScript code can use these to interact with the Document Object Model (DOM), perform network communication, integrate with native device features, and much more.” (WbAPICook 2024)
Polyfills
”Older browsers can take advantage of some of these Web APIs by using polyfills. A polyfill is a JavaScript library that implements missing JavaScript functionality. Polyfills are typically used for web API features that aren’t implemented in older browsers.“ (WbAPICook 2024)
“While beneficial, polyfills do have some drawbacks:
- They are loaded as third-party libraries, which add to your JavaScript bundle size.
- They generally aren’t maintained by the browser teams, so there may be bugs or inconsistencies.
The Power of Modern Browsers
“Modern web APIs have two big advantages for the web platform:
- “No more plug-ins - In the past, much of this functionality was only available to native applications or clunky browser plug-ins. (Remember ActiveX and Flash?)
Drawbacks of Third-Party Libraries
Third-party libraries can be helpful with older browsers or newer functionality, but they have some costs:
More code to download
Using libraries increases the amount of JavaScript the browser has to load. Whether it’s bundled with your app or loaded separately from a content delivery network (CDN), your browser still has to download it. This translates into potentially longer loading times and higher battery usage on mobile devices.
Increased risk
Open source libraries, even popular ones, can be abandoned. When bugs or security vulnerabilities are found, there’s no guarantee of an update. Browsers, in general, are supported by large companies (the major browsers are from Google, Mozilla, Apple, and Microsoft), and it’s more likely that these issues will be fixed.
This isn’t to say that third-party libraries are bad. There are many benefits as well, especially if you need to support older browsers. Like everything in software development, library use is a balancing act.
Who This Book Is For
This book is intended for software developers with some experience with JavaScript who want to get the most out of the web platform.
It assumes that you have a good knowledge of the JavaScript language itself: syntax, language features, and standard library functions. You should also have a working knowledge of the DOM APIs used for building interactive, browser-based JavaScript applications.
There is a wide range of recipes in this book; there’s something for developers of all skill and experience levels.
What’s in This Book
Each chapter contains a set of recipes—code examples for accomplishing a specific task. Each recipe has three sections:
Problem
Describes the problem the recipe solves.
Solution
Contains code and explanation that implements the recipe solution.
Discussion
A deeper discussion of the topic. This section may contain additional code examples and comparisons with other techniques.
Code samples and live demos are on the companion website, https://WebAPIs.info.
Additional Resources
“By its nature, the web is changing all the time. There are many great resources available online to help clarify any questions that might come up.” (WbAPICook 2024)
CanIUse.com
“At the time of writing, some APIs in this book are still in development or an “experimental” phase. Watch for compatibility notes in recipes that use these APIs. For most features, you can check the latest compatibility data at CanIUse.com (https://CanIUse.com). You can search by the name of a feature and see the latest information about which browser versions support the API and any limitations or caveats for particular browser versions.” (WbAPICook 2024)
MDN Web Docs
”MDN Web Docs is the de facto API documentation for all things web. It covers all the JavaScript APIs from this book in great detail, as well as other topics such as CSS and HTML. It contains in-depth articles and JavaScript tutorials as well as Web API specifications.” (WbAPICook 2024)
Specifications
“When in doubt, the API specification of a feature or API is the definitive resource. They aren’t the most exciting reads, but they are a good place to look for details about edge cases or expected behavior.” (WbAPICook 2024)
“Different APIs have different standards, but most can be found either from the Web Hypertext Application Technology Working Group (WHATWG) or the World Wide Web Consortium (W3C).” (WbAPICook 2024)
“The standards for ECMAScript (which specifies features in the JavaScript Language) are maintained and developed by the Ecma International Technical Committee 39, better known as TC39.” (WbAPICook 2024)
Conventions Used in This Book
The following typographical conventions are used in this book:
Italic
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.
Tip
This element signifies a tip or suggestion.
Note
This element signifies a general note.
Warning
This element indicates a warning or caution.
Using Code Examples
“Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/joeattardi/web-api-cookbook. Also check out the companion website, where many of the code samples and recipes in this book are expanded into full, live, working examples.” (WbAPICook 2024)
Fair Use Sources
Cloud Monk is Retired ( for now). Buddha with you. © 2025 and Beginningless Time - Present Moment - Three Times: The Buddhas or Fair Use. Disclaimers
SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.