https://github.com/jadjoubran/promyfill
🔥 450Bytes Promise based conditional polyfill loader
https://github.com/jadjoubran/promyfill
conditional polyfill promise promyfill
Last synced: 11 days ago
JSON representation
🔥 450Bytes Promise based conditional polyfill loader
- Host: GitHub
- URL: https://github.com/jadjoubran/promyfill
- Owner: jadjoubran
- Created: 2017-04-11T16:57:03.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-28T14:56:19.000Z (about 8 years ago)
- Last Synced: 2025-04-15T20:08:03.832Z (6 months ago)
- Topics: conditional, polyfill, promise, promyfill
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 15
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Promyfill
Promyfill saves you from shipping polyfill code to all browsers.
Your own polyfill URL will be loaded only if needed.✅ Promyfill is ~450 Bytes.
# Usage
## Fetch example
```javascript
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');
});
```## Alternate usage
```javascript
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');
});
```## Intersection observer example
```javascript
const ioPolyfill = 'https://rawgit.com/WICG/IntersectionObserver/gh-pages/polyfill/intersection-observer.js';promyfill('IntersectionObserver' in window, ioPolyfill).then(() => {
const io = new IntersectionObserver(() => {});
})
```# "Promises" support
Promyfill relies on native promises available in most modern browsers, except a [few](http://caniuse.com/#search=promise) such as IE11, Android 4.4].
In order to support these browsers, you can also include the tiny [promis](https://github.com/bramstein/promis) from bramstein# Video explanation
[](https://www.youtube.com/watch?v=p84a0i34_08 "Promyfill video")
# Feedback
This is a PWA experiment, usage & motivation detailed in this [Medium article](https://medium.com/@JoubranJad/progressive-web-app-experiment-promyfill-900faddda22f)
For feedback or questions, please open a new issue.