@@ -56,12 +56,6 @@ const relPreloadStyle = 'fetch'
56
56
57
57
const hasNoModule = 'noModule' in document . createElement ( 'script' )
58
58
59
- const requestIdleCallback : ( fn : ( ) => void ) => void =
60
- ( window as any ) . requestIdleCallback ||
61
- function ( cb : ( ) => void ) {
62
- return setTimeout ( cb , 1 )
63
- }
64
-
65
59
function normalizeRoute ( route : string ) {
66
60
if ( route [ 0 ] !== '/' ) {
67
61
throw new Error ( `Route name should start with a "/", got "${ route } "` )
@@ -281,20 +275,19 @@ export default class PageLoader {
281
275
const { pathname : hrefPathname } = parseRelativeUrl ( href )
282
276
const route = normalizeRoute ( hrefPathname )
283
277
return this . promisedSsgManifest ! . then (
284
- ( s : ClientSsgManifest , _dataHref ?: string ) => {
285
- requestIdleCallback ( ( ) => {
286
- // Check if the route requires a data file
287
- s . has ( route ) &&
288
- // Try to generate data href, noop when falsy
289
- ( _dataHref = this . getDataHref ( href , asPath , true ) ) &&
290
- // noop when data has already been prefetched (dedupe)
291
- ! document . querySelector (
292
- `link[rel=" ${ relPrefetch } "][href^=" ${ _dataHref } "]`
293
- ) &&
294
- // Inject the `<link rel=prefetch>` tag for above computed `href`.
295
- appendLink ( _dataHref , relPrefetch , 'fetch' )
278
+ ( s : ClientSsgManifest , _dataHref ?: string ) =>
279
+ // Check if the route requires a data file
280
+ s . has ( route ) &&
281
+ // Try to generate data href, noop when falsy
282
+ ( _dataHref = this . getDataHref ( href , asPath , true ) ) &&
283
+ // noop when data has already been prefetched (dedupe)
284
+ ! document . querySelector (
285
+ `link[rel=" ${ relPrefetch } "][href^=" ${ _dataHref } "]`
286
+ ) &&
287
+ // Inject the `<link rel=prefetch>` tag for above computed `href`.
288
+ appendLink ( _dataHref , relPrefetch , 'fetch' ) . catch ( ( ) => {
289
+ /* ignore prefetch error */
296
290
} )
297
- }
298
291
)
299
292
}
300
293
0 commit comments