Promyfill saves you from shipping polyfill code to all browsers.
Your own polyfill URL will be loaded only if needed.
✅ Promyfill is ~450 Bytes.
const fetchPolyfill = 'https://rawgit.com/github/fetch/master/fetch.js';
promyfill(window.fetch, fetchPolyfill).then((fetch) => {
//fetch is available (polyfill is fetched only if needed)
fetch('users.json');
});
const fetchPolyfill = 'https://rawgit.com/github/fetch/master/fetch.js';
promyfill('fetch' in window, fetchPolyfill).then(() => {
//fetch is available (polyfill is fetched only if needed)
fetch('users.json');
});
const ioPolyfill = 'https://rawgit.com/WICG/IntersectionObserver/gh-pages/polyfill/intersection-observer.js';
promyfill('IntersectionObserver' in window, ioPolyfill).then(() => {
const io = new IntersectionObserver(() => {});
})
Promyfill relies on native promises available in most modern browsers, except a few such as IE11, Android 4.4].
In order to support these browsers, you can also include the tiny promis from bramstein
This is a PWA experiment, usage & motivation detailed in this Medium article
For feedback or questions, please open a new issue.