1 // Convenience function to load polyfills and return a promise when it's done.
2 // If there are no polyfills, then this is just Promise.resolve() which means
3 // it will execute in the same tick of the event loop (i.e. near-instant).
5 function importBasePolyfills() {
6 return import(/* webpackChunkName: "base_polyfills" */ './base_polyfills');
9 function importExtraPolyfills() {
10 return import(/* webpackChunkName: "extra_polyfills" */ './extra_polyfills');
13 function loadPolyfills() {
14 const needsBasePolyfills
= !(
15 Array
.prototype.includes
&&
16 HTMLCanvasElement
.prototype.toBlob
&&
24 // Latest version of Firefox and Safari do not have IntersectionObserver.
25 // Edge does not have requestIdleCallback and object-fit CSS property.
26 // This avoids shipping them all the polyfills.
27 const needsExtraPolyfills
= !(
28 window
.IntersectionObserver
&&
29 window
.IntersectionObserverEntry
&&
30 'isIntersecting' in IntersectionObserverEntry
.prototype &&
31 window
.requestIdleCallback
&&
32 'object-fit' in (new Image()).style
36 needsBasePolyfills
&& importBasePolyfills(),
37 needsExtraPolyfills
&& importExtraPolyfills(),
41 export default loadPolyfills
;