-
Notifications
You must be signed in to change notification settings - Fork 28.3k
External library code gets loaded on blank page where library is not used #57337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @smitbarmase Next.js has a prefetching mechanism that loads the instant-loading-state content of links on the page. Your Aside from it being surprising if you aren't aware of the prefetching behavior is the the fetchign of swiper problematic? |
Hey @gnoff , I am aware of the prefetching behavior of Next.js's Link component. I am using the Additionally, the Swiper library introduces 40-50 KB of redundant code to pages that do not use it. |
@smitbarmase indeed I missed that :) I've taken a closer look and there does seem to be something up with the dependencies between a client component and that chunk. Initially I thought it might be an instance where webpack makes fewer larger chunks to avoid having too many small ones and it just happens to include this chunk on the |
Sure, @gnoff, it seems there's an issue with how Webpack bundles things. Also, the workaround I've found is to make a copy of the |
This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you. |
Link to the code that reproduces this issue
https://github.com/smitbarmase/webpack-bundle-bug
To Reproduce
swiper
is only used on/
page and not on/about-us
./about-us
, search forswiper
keyword in chunks./about-us
multiple times, you will seeswiper
chunks still getting downloaded.Screenshot of network tab of

/about-us
after searchingswiper
in chunks:Current vs. Expected behavior
Currently,
swiper
chunks getting downloaded on/about-us
page, which is empty.Expected behavior would be
swiper
chunks gets downloaded only on home page/
asswiper
is used only on that page.Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000 Binaries: Node: 20.6.1 npm: 9.8.1 Yarn: N/A pnpm: 8.7.1 Relevant Packages: next: 13.5.7-canary.23 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
App Router, Routing (next/router, next/navigation, next/link)
Additional context
No response
The text was updated successfully, but these errors were encountered: