Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
perf: prefetch in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Sep 13, 2022
1 parent 3207ff4 commit b7bea15
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/nuxt/src/app/components/nuxt-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,10 @@ export function defineNuxtLink (options: NuxtLinkOptions) {
unobserve = observer!.observe(el.value, async () => {
unobserve?.()
unobserve = null
await nuxtApp.hooks.callHook('link:prefetch', to.value as string).catch(() => {})
await preloadRouteComponents(to.value as string, router).catch(() => {})
await Promise.all([
nuxtApp.hooks.callHook('link:prefetch', to.value as string).catch(() => {}),
preloadRouteComponents(to.value as string, router).catch(() => {})
])
prefetched.value = true
})
}
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/basic/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div>Composable | bar: {{ bar }}</div>
<div>Composable | template: {{ templateAutoImport }}</div>
<div>Path: {{ $route.fullPath }}</div>
<NuxtLink to="/" no-prefetch>
<NuxtLink to="/">
Link
</NuxtLink>
<SugarCounter :count="12" />
Expand Down

0 comments on commit b7bea15

Please sign in to comment.