Reputation: 779
I'm using nextjs on vercel.
Making google lighthouse pagespeed test, on my homepage.
It returns "remove unused javascripts", And It lists my other staticprops pages' javascript files like;
privacy-policy.js
gdpr.js
shopping-cart.js etc.
Why It loads other pages, while I am not on those pages? How can I stop it? They must be loaded at only their own url.
Upvotes: 1
Views: 2979
Reputation: 2165
NextJS do prefetch
on default for linked routes.
you can disable it to avoid loading other pages:
<Link href="path" prefetch={false} />
Upvotes: 5
Reputation: 130
When using getStaticProps, the build time happens when the package is built.
If you want to build the page only when you go on it, you should use getServerSideProps
.
Upvotes: 0