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-rc.8 prefetches all pages (ssr: false)

See original GitHub issue

Environment

  • 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:closed
  • Created a year ago
  • Reactions:7
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
danielroecommented, Aug 15, 2022

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:

  1. we can merge prefetch support via NuxtLink (https://github.com/nuxt/framework/pull/4329 currently awaiting review from @pi0)
  2. we can remove page chunks from dynamic imports in manifest
  3. we can support programmatic prefetching of global components
  4. (optionally) add a plugin to update manifest so that the components that might use global components are the ones that have the dynamic import registered
2reactions
pi0commented, Aug 15, 2022

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…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Route prefetching in Next.js - web.dev
When you load a page with a few links, odds are that by the time you follow a link, the component behind it...
Read more >
Release Notes - Nuxt
Discover all the release notes for the Nuxt framework.
Read more >
How to Disable Server-Side Rendering (SSR) in Next.js
Step 1: Rewrite All Requests to pages/index.js · Step 2: Disable SSR for Page Content · Step 3: Check that Everything Works with...
Read more >
Implementing SSR in Next.js: Dynamic routing and prefetching
This means every page will use static site generation by default, one of the two rendering options that make up the hybrid architecture...
Read more >
Getting started with Next.js - Montecha
Next.js is a React framework to do all of this effortlessly and has ... which automatically prefetches page resources in the background.
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