mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 07:40:33 +00:00
fix(nuxt): defer registering inp handler until nuxt is mounted
This commit is contained in:
parent
e7fbc9f815
commit
866a5319a3
@ -1,8 +1,11 @@
|
||||
import { defineNuxtPlugin } from '../nuxt'
|
||||
import { useRouter } from '../composables'
|
||||
import { onNuxtReady } from '../composables/ready'
|
||||
import { useRouter } from '../composables/router'
|
||||
|
||||
export default defineNuxtPlugin(() => {
|
||||
useRouter().beforeResolve(async () => {
|
||||
const router = useRouter()
|
||||
onNuxtReady(() => {
|
||||
router.beforeResolve(async () => {
|
||||
/**
|
||||
* This gives an opportunity for the browser to repaint, acknowledging user interaction.
|
||||
* It can reduce INP when navigating on prerendered routes.
|
||||
@ -16,4 +19,5 @@ export default defineNuxtPlugin(() => {
|
||||
requestAnimationFrame(() => { setTimeout(resolve, 0) })
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user