Foreword - Building Polyfills: Web Platform APIs for the Present and Future (2014)

Building Polyfills: Web Platform APIs for the Present and Future (2014)

Foreword

Polyfill, a word synonymous with fallback, is a term which has become all too familiar with developers building modern web apps targeting nonmodern browsers. In the past, however, much of the guidance around authoring them was limited to out of date resources, often leaving developers to fend for their own.

I’m happy to say that the lack of a definitive resource for learning how to build robust polyfills is filled by this excellent book, allowing you to spend less time striking out on your own and more time building a reliable solution that won’t let you down.

In this practical guide, you will be shown through the fundamental principles and guidelines for building polyfills that users can rely on. Learn how to responsibly match the APIs specified by the web platform features you’re targeting and deliver a solution which is focused and does one thing well. It can be a challenge to understand the ins and outs of platform features, but this guide cuts through the nonsense, helping you understand web platform features so that you can deliver complete polyfills which won’t frustrate developers.

In the fast-paced world of frontend development, polyfills are no longer strictly used for delivering modern features to older browsers, but also to enable developers to use experimental platform features. This hints at the potential for polyfills to be around far longer than when all browsers become evergreen (or auto-updating).

Walk through an introduction to polyfilling, discover the core principles for building reliable polyfills, and then move on to an in-depth explanation of developing a real-world, nontrivial polyfill—the HTML5 Forms polyfill. Brandon talks about emerging trends such as the “experimental feature” polyfill and how this has been a successful pattern for W3C specifications like Web Components, encompassing Custom Elements, HTML Imports, and other technologies.

Building Polyfills is an invaluable resource which will teach you lessons that can be easily reused to write reliable polyfills today and in the future. I found it filled with useful best practices, original thinking, and pro-tips that make it an important reference book for anyone serious about writing cross-browser polyfills.

—Addy Osmani, Chrome Developer Relations