Created
September 22, 2017 08:48
-
-
Save aganglada/61a023e31efe4f228338e91516dadf7b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loadPolyfills() | |
.then(() => /* Render React application now that your Polyfills are ready */) | |
/** | |
* Do feature detection, to figure out which polyfills needs to be imported. | |
**/ | |
function loadPolyfills() { | |
const polyfills = [] | |
if (!supportsIntersectionObserver()) { | |
polyfills.push(import('intersection-observer')) | |
} | |
return Promise.all(polyfills) | |
} | |
function supportsIntersectionObserver() { | |
return ( | |
'IntersectionObserver' in global && | |
'IntersectionObserverEntry' in global && | |
'intersectionRatio' in IntersectionObserverEntry.prototype | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment