mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-16 10:54:49 +00:00
12 lines
357 B
TypeScript
12 lines
357 B
TypeScript
import { useNuxtApp } from '../nuxt'
|
|
import { requestIdleCallback } from '../compat/idle-callback'
|
|
|
|
export const onNuxtReady = (callback: () => any) => {
|
|
const nuxtApp = useNuxtApp()
|
|
if (nuxtApp.isHydrating) {
|
|
nuxtApp.hooks.hookOnce('app:suspense:resolve', () => { requestIdleCallback(callback) })
|
|
} else {
|
|
requestIdleCallback(callback)
|
|
}
|
|
}
|