The content is now here: https://exploringjs.com/impatient-js/ch_modules.html#polyfills
-
-
Save rauschma/6a431d51d60a6123982759e6a8579420 to your computer and use it in GitHub Desktop.
Agreed with @simevidas, the term polyfill, as meant on the web, has nothing to do with new vs old, it's about bringing standard features to browsers that don't support those, no matter how old or modern these are.
As example, Custom Elements built-in extends is defined by standard V1 API but Safari doesn't implement it yet, so that a polyfill for Safari only is needed, while Firefox, Chrome, Opera, or newest Edge are fine.
Shall we add the difference between Polyfill and Ponyfill?
It may be worth saying: it adds that feature to the platform by implementing the standard API in JavaScript. That is: it doesn't just add the feature; it adds the feature exactly as supporting browsers do, so a developer can programme to the standard API and it'll work even on browsers that don't natively provide it.
@simevidas, @WebReflection: Thanks for your feedback! I have rewritten the text.
@rauschma that sounds better, yes, but I'd still change one part:
installs that feature on a platform that doesn’t already support it
this feels like a permanent change on the host/user machine
implements that feature on a platform that doesn’t already support it
or even
provides that feature on a platform that doesn’t already support it
seems to be a better wording choice. Eventually, I'd add at runtime to explicit such feature is not permanent.
P.S. since you mentioned the word shim, I'd also mention the word sham, used to indicate the provided feature doesn't fully comply with the standard, due lack of primitives, or due developer intent to bring only partially the mentioned feature.
@WebReflection. Fixed, thanks! I only want to describe the most common terms. I hadn’t seen “sham” before yesterday.
the oldest usage of it I’m aware of is the es5-sham (a file in the es5-shim)
@ljharb I never noticed it before yesterday (I have known and used es5-shim for years).
¯\_(ツ)_/¯ also es6-shim has an es6-sham. a comparable term for "polyfill" is "prollyfill".
Note: My goal is not comprehensiveness, my goal is to bring beginners up to speed, without overwhelming them. Accordingly, I’m trying to answer two questions:
- What terms will newcomers see often?
- What concepts should they know about?
I don’t like the term “prollyfill” (as a non-native speaker, I only recently realized that the “prolly” may stand for “probably”). The following document suggests the alternative “speculative polyfill” which I find more intuitive: https://www.w3.org/2001/tag/doc/polyfills/
web feature → web platform feature
run on older browsers → run on browsers that don’t support this feature
brings a new feature to older platforms → adds support for a feature to browsers that don’t support it natively
by making global changes… → using JavaScript