Debug Navigation performance Issues
Navigating to pages with the nuxtlink component takes ages. Sometime up to 3s. How can I debug this?
13 Replies
Hi @Samuelreichoer. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To debug slow navigation performance with the
Use Nuxt DevTools to gain insights into your app's performance. The Timeline feature tracks time spent on rendering, updating, and initializing components, helping you identify bottlenecks during navigation. The Render Tree and Inspect features can also help you see which components and files are loaded and their impact on performance Nuxt DevTools. 2. Chrome DevTools
Open the Performance tab in Chrome DevTools to record and analyze navigation events. This will show you metrics like Largest Contentful Paint (LCP), Cumulative Layout Shift (CLS), and Interaction to Next Paint (INP), which are crucial for understanding navigation delays Chrome DevTools. 3. browserDevtoolsTiming Experimental Feature
Enable the
By default,
Use the
Use lazy loading (
<NuxtLink> component in Nuxt, you can use several built-in tools and best practices:
1. Nuxt DevToolsUse Nuxt DevTools to gain insights into your app's performance. The Timeline feature tracks time spent on rendering, updating, and initializing components, helping you identify bottlenecks during navigation. The Render Tree and Inspect features can also help you see which components and files are loaded and their impact on performance Nuxt DevTools. 2. Chrome DevTools
Open the Performance tab in Chrome DevTools to record and analyze navigation events. This will show you metrics like Largest Contentful Paint (LCP), Cumulative Layout Shift (CLS), and Interaction to Next Paint (INP), which are crucial for understanding navigation delays Chrome DevTools. 3. browserDevtoolsTiming Experimental Feature
Enable the
browserDevtoolsTiming experimental feature in your nuxt.config.ts to add performance markers for Nuxt hooks in the browser devtools. This helps you track exactly where time is spent during navigation in the Performance panel of Chromium-based browsers:
This is enabled by default in development mode browserDevtoolsTiming.
4. NuxtLink PrefetchingBy default,
<NuxtLink> uses smart prefetching, which can sometimes cause delays if too much is prefetched. You can change the prefetching strategy to only prefetch on interaction:
This can help reduce unnecessary network requests and speed up navigation Links.
5. Nuxi AnalyzeUse the
nuxi analyze command to visualize your production bundle. Large blocks in the visualization may indicate components or libraries that are slowing down navigation. Consider lazy loading or splitting large components Nuxi Analyze.
6. Check for Lazy Loading and HydrationUse lazy loading (
Lazy prefix) and lazy hydration (hydrate-on-visible) for components that are not immediately needed. This reduces the initial JavaScript bundle size and can improve navigation speed Lazy Loading Components, Lazy Hydration.
By combining these tools and strategies, you can pinpoint and address the causes of slow navigation in your Nuxt app. If you still experience issues, use the Timeline and Performance panels to identify specific components or network requests that are causing delays.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1065266379382587422> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Hi
Does the target page include any awaited useAsyncData ?
Hi, yes it does
Tldr it's probably the issue
Benoît Deveaux
StackBlitz
Nuxt - Starter - StackBlitz
Create a new Nuxt project, module, layer or start from a theme with our collection of starters.
Already did long messages days and weeks agos, never had any official response
Oh man, thank you I will try to remove my awaits and check if this helps.. strange that the nuxt team does not look into this. Seems to be a big issue..
Not even an issue
It's misunderstandings of nuxt team at this point 🙁
I wont harass people about open source stuff so, I just gave up the fact that it will never ba clarified
Okey but that's a bad design 😅 If no one should use await, why is it allowed to use
I think that's feedback from the community that is important and makes the framework better
There are lazy which half fix that
Si you add a option to bypass a keyword which is not required :this_is_fine_anim:
Try to ask, every 6 month I ask I got ignored
Dang, i had an await in a catch all route, I removed it and the site feels snappy now 😅
nice