HTML and CSS Reference
In-Depth Information
yep : 'localstorage.js' ,
nope : 'localstorage-polyfill.js'
Moving on, let's explore the concept of a polyfill and how you can use it to plug features
that aren't supported by a given browser.
2.5.2. Using polyfills and Modernizr to plug the gaps
The term polyfill was coined by Remy Sharp and refers to a piece of code (or shim) that
aims to implement missing parts of an API specification. The origin of the term is from a
product named Polyfilla, which builders use to fill gaps or cracks in walls. Likewise, we
developers can use polyfills to fill the gaps or cracks in various web browsers' support for
Paul Irish, one of the key contributors to the Modernizr library, edits and maintains a com-
prehensive list of polyfills, shims, and fallbacks for a wide variety of HTML5 features.
This list is available on Modernizr's GitHub wiki at: .
Step 1: Build feature detection and conditionally deploy a fallba- ack for month-picker
Let's look at how to use Modernizr to load a month-picker polyfill into those browsers
without a built-in month-picker. We expect that you've already placed the monthpicker.js
file from this chapter's source code (available at ) in the
same directory as the files you've been building in this chapter. Now add the code from
the next listing to the end of the init function, directly after the code you added from the
previous listing.
Search WWH ::

Custom Search