perf: lazy-lazy-load the :focus-visible polyfill (#1785)
This commit is contained in:
parent
a790004be7
commit
f080148aad
|
@ -1,14 +1,20 @@
|
||||||
import './routes/_thirdparty/regenerator-runtime/runtime.js'
|
import './routes/_thirdparty/regenerator-runtime/runtime.js'
|
||||||
import * as sapper from '../__sapper__/client.js'
|
import * as sapper from '../__sapper__/client.js'
|
||||||
import { loadPolyfills } from './routes/_utils/loadPolyfills'
|
|
||||||
import './routes/_utils/serviceWorkerClient'
|
import './routes/_utils/serviceWorkerClient'
|
||||||
import './routes/_utils/historyEvents'
|
import './routes/_utils/historyEvents'
|
||||||
import './routes/_utils/loadingMask'
|
import './routes/_utils/loadingMask'
|
||||||
import './routes/_utils/forceOnline'
|
import './routes/_utils/forceOnline'
|
||||||
|
import { mark, stop } from './routes/_utils/marks'
|
||||||
|
import { loadPolyfills } from './routes/_utils/loadPolyfills'
|
||||||
|
import { loadNonCriticalPolyfills } from './routes/_utils/loadNonCriticalPolyfills'
|
||||||
|
|
||||||
|
mark('loadPolyfills')
|
||||||
loadPolyfills().then(() => {
|
loadPolyfills().then(() => {
|
||||||
console.log('init()')
|
stop('loadPolyfills')
|
||||||
|
mark('sapperStart')
|
||||||
sapper.start({ target: document.querySelector('#sapper') })
|
sapper.start({ target: document.querySelector('#sapper') })
|
||||||
|
stop('sapperStart')
|
||||||
|
/* no await */ loadNonCriticalPolyfills()
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('process.env.NODE_ENV', process.env.NODE_ENV)
|
console.log('process.env.NODE_ENV', process.env.NODE_ENV)
|
||||||
|
|
8
src/routes/_utils/loadNonCriticalPolyfills.js
Normal file
8
src/routes/_utils/loadNonCriticalPolyfills.js
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import { supportsSelector } from './supportsSelector'
|
||||||
|
import { importFocusVisible } from './asyncPolyfills'
|
||||||
|
|
||||||
|
export function loadNonCriticalPolyfills () {
|
||||||
|
return Promise.all([
|
||||||
|
!supportsSelector(':focus-visible') && importFocusVisible()
|
||||||
|
])
|
||||||
|
}
|
|
@ -1,12 +1,10 @@
|
||||||
import {
|
import {
|
||||||
importCustomElementsPolyfill,
|
importCustomElementsPolyfill,
|
||||||
importFocusVisible,
|
|
||||||
importIndexedDBGetAllShim,
|
importIndexedDBGetAllShim,
|
||||||
importIntersectionObserver,
|
importIntersectionObserver,
|
||||||
importIntl,
|
importIntl,
|
||||||
importRequestIdleCallback
|
importRequestIdleCallback
|
||||||
} from './asyncPolyfills'
|
} from './asyncPolyfills'
|
||||||
import { supportsSelector } from './supportsSelector'
|
|
||||||
|
|
||||||
export function loadPolyfills () {
|
export function loadPolyfills () {
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
|
@ -14,7 +12,6 @@ export function loadPolyfills () {
|
||||||
typeof requestIdleCallback === 'undefined' && importRequestIdleCallback(),
|
typeof requestIdleCallback === 'undefined' && importRequestIdleCallback(),
|
||||||
!IDBObjectStore.prototype.getAll && importIndexedDBGetAllShim(),
|
!IDBObjectStore.prototype.getAll && importIndexedDBGetAllShim(),
|
||||||
typeof customElements === 'undefined' && importCustomElementsPolyfill(),
|
typeof customElements === 'undefined' && importCustomElementsPolyfill(),
|
||||||
process.env.LEGACY && typeof Intl === 'undefined' && importIntl(),
|
process.env.LEGACY && typeof Intl === 'undefined' && importIntl()
|
||||||
!supportsSelector(':focus-visible') && importFocusVisible()
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue