From b42bdd80e8a25f0ea5d121431265b428a34d1a65 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Tue, 30 May 2017 06:11:15 -0700 Subject: Extract polyfill loading into single module (#3421) --- app/javascript/packs/application.js | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) (limited to 'app/javascript/packs/application.js') diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index be40726c6..8932dc513 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -1,32 +1,6 @@ import main from '../mastodon/main'; +import loadPolyfills from '../mastodon/load_polyfills'; -const needsBasePolyfills = !( - window.Intl && - Object.assign && - Number.isNaN && - window.Symbol && - Array.prototype.includes -); - -const needsExtraPolyfills = !( - window.IntersectionObserver && - window.requestIdleCallback -); - -// Latest version of Firefox and Safari do not have IntersectionObserver. -// Edge does not have requestIdleCallback. -// This avoids shipping them all the polyfills. -if (needsBasePolyfills) { - Promise.all([ - import(/* webpackChunkName: "base_polyfills" */ '../mastodon/base_polyfills'), - import(/* webpackChunkName: "extra_polyfills" */ '../mastodon/extra_polyfills'), - ]).then(main).catch(e => { - console.error(e); // eslint-disable-line no-console - }); -} else if (needsExtraPolyfills) { - import(/* webpackChunkName: "extra_polyfills" */ '../mastodon/extra_polyfills').then(main).catch(e => { - console.error(e); // eslint-disable-line no-console - }); -} else { - main(); -} +loadPolyfills().then(main).catch(e => { + console.error(e); // eslint-disable-line no-console +}); -- cgit