Nuxt-rc.8 prefetches all pages (ssr: false)
See original GitHub issueEnvironment
- Operating System:
Darwin
- Node Version:
v18.7.0
- Nuxt Version:
3.0.0-rc.8
- Package Manager:
npm@8.17.0
- Builder:
vite
- User Config:
ssr
- Runtime Modules:
-
- Build Modules:
-
Reproduction
You can clone https://github.com/stenet/nuxt-many-pages and run
nuxt build
to see the result (.output/public/index.html) with Nuxt-rc.6. After that update to Nuxt-rc.8 and rebuild again. You should see the massive increase.
Describe the bug
I did a few tests with a lot of pages.
In Nuxt-rc.6, after building the app, the .output/public/index.html had only the entry.xxx.mjs as script and a total size of about 300 bytes.
After upgrading to Nuxt-rc.8, the index.html has every page in the app as as link prefetch script and a total size of about 87 kilobytes. Btw the entry.xxx.mjs is added twice (1x as script + 1x as link).
Also I understand this from the point of better performance when navigating/loading such a page the first time, but I think that this behavior is rather suboptimal when the app has many pages of which the user calls only a few of them (or has no access) and the browser cache is “filled up” with a lot of unnecessary content.
Additional context
No response
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:7
- Comments:7 (6 by maintainers)
Top GitHub Comments
Currently dynamic imports include things like routes, error components, and any global components (so if using with
@nuxt/content
). I am very concerned to decrease HTML and number of prefetched resources but if we simply disable prefetching, sites will seem much slower.From my point of view, before removing current prefetch behaviour, we need the ability to make some finer-grained decisions.
A set of (ordered) suggestions:
prefetch
support via NuxtLink (https://github.com/nuxt/framework/pull/4329 currently awaiting review from @pi0)I believe default prefetching behavior for SPA should be non when we cannot predict sibling routes this can grow infinity and indeed later we can enable other prefetching mechanisms such as relying on links and intersection observer…