question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nuxt 3 prefetch all assets from every pages and every layouts.

See original GitHub issue

Environment

Nuxt CLI v3.0.0-rc.0 Nuxt project info:


  • Operating System: Darwin
  • Node Version: v16.14.0
  • Nuxt Version: 3.0.0-rc.0
  • Package Manager: npm@8.3.1
  • Builder: vite
  • User Config: css
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/kstraszewski/nuxt3-playground/tree/prefetching-all-assets

Also we have qa version of our project here: https://b2c.qa2.lendi.pl/design

Describe the bug

Nuxt after build prefetch all the assets like CSS, fonts, media, imgs from all the pages and all the layouts. As you can see in the repo example you have /pageA which implement layout-a, with some video in the pageA.vue. Also, you have /pageB which implements layout-b which loads popular @mdi/font.

The problem I have is it doesn’t matter on which page you go nuxt always loads all the assets. When you go to /pageA you will see the mdi fonts from pageB and layoutB also are prefetching by the nuxt:

PageA: image

PageB: image

Both pages Loads a lot.

My guess is that vite builder prefetch every URL that he find in CSS or template.

Additional context

It makes nuxt unusable in production mode because It hurts LCP very badly:

As you can see on the example below we have huge LCP (I’ve made some tricks witch mdi/fonts, but this is very ugly solution) with fully loaded mdi/fonts I’ve received 27 sec of LCP.

https://pagespeed.web.dev/report?url=https%3A%2F%2Fb2c.qa2.lendi.pl%2Fdesign

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:33
  • Comments:26 (7 by maintainers)

github_iconTop GitHub Comments

17reactions
kosmelncommented, Jul 25, 2022

We can’t wait to see this fixed sooner! Fingers crossed!

9reactions
danielroecommented, Jul 4, 2022

There is a difference between preload and prefetch. There is an issue awaiting review that prevents over-zealous prefetching: https://github.com/nuxt-contrib/vue-bundle-renderer/pull/30.

There is another issue which is that the vite manifest that is built includes too many assets as direct dependencies of the entry point.

Yes, this is planned to be resolved. Likely we need to merge https://github.com/nuxt/framework/pull/5398 first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pages directory - Nuxt
The pages directory contains your Application Views and Routes. Nuxt reads all the .vue files inside this directory and automatically creates the router ......
Read more >
Nuxt 3 full course build and deploy | #Nuxtjs #vue #nuxt3
... all its new features in the #nuxt3 application nuxt 3 Course is for beginners and cover full course to advanced level It...
Read more >
Nuxt 3 Crash Course #6 - Layouts - YouTube
In this Nuxt lesson, you'll lear how to make layout files for your pages. Watch the whole course now (without ads) on Net...
Read more >
Nuxt.js cheat sheet - Christopher Kade
Nuxt will also make sure to set everything up for you, all you'll have to do is ... 1// /pages/about.vue 2 3<template> 4...
Read more >
Nuxt 3 Beta: What's New and How to Get Started - SitePoint
Nuxt 3 version is aligned with Vue 3 so you can leverage all the great ... Now we can reuse this layout in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found