pinafore/src/routes/_utils/loadPolyfills.js
Nolan Lawson 260f6acf0e
perf: download and cache polyfills on-the-fly (#814)
* perf: download and cache polyfills on-the-fly

* fixup the localhost switch for service worker, does nothing
2018-12-15 17:13:46 -08:00

17 lines
619 B
JavaScript

import {
importCustomElementsPolyfill,
importIndexedDBGetAllShim,
importIntersectionObserver,
importRequestIdleCallback,
importWebAnimationPolyfill
} from './asyncPolyfills'
export function loadPolyfills () {
return Promise.all([
typeof IntersectionObserver === 'undefined' && importIntersectionObserver(),
typeof requestIdleCallback === 'undefined' && importRequestIdleCallback(),
!Element.prototype.animate && importWebAnimationPolyfill(),
!IDBObjectStore.prototype.getAll && importIndexedDBGetAllShim(),
typeof customElements === 'undefined' && importCustomElementsPolyfill()
])
}