mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-21 21:25:11 +00:00
perf(nuxt): prevent head dom from rendering twice (#22974)
This commit is contained in:
parent
4e05650cde
commit
421cab1adf
@ -26,7 +26,10 @@ export default defineNuxtPlugin({
|
||||
head.hooks.hook('dom:beforeRender', (context) => { context.shouldRender = !pauseDOMUpdates })
|
||||
nuxtApp.hooks.hook('page:start', () => { pauseDOMUpdates = true })
|
||||
// wait for new page before unpausing dom updates (triggered after suspense resolved)
|
||||
nuxtApp.hooks.hook('page:finish', syncHead)
|
||||
nuxtApp.hooks.hook('page:finish', () => {
|
||||
// app:suspense:resolve hook will unpause the DOM
|
||||
if (!nuxtApp.isHydrating) { syncHead() }
|
||||
})
|
||||
// unpause on error
|
||||
nuxtApp.hooks.hook('app:error', syncHead)
|
||||
// unpause the DOM once the mount suspense is resolved
|
||||
|
Loading…
Reference in New Issue
Block a user