Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why nextjs loads all pages at first load when i build

I'm using nextJS for my new website, but SEO and speed of the site is of very importance matter for me. What I'm trying to do is prevent loading of extra resource files while I have no need for them. For example when I'm at the Home page, I do not need resources for faq or about page be loaded in the background. Is there anyway I can possibly prevent these extra loads on my site?

Thank you in advance

loads all pages

like image 845
Elyas Pourmotazedy Avatar asked Oct 28 '25 05:10

Elyas Pourmotazedy


1 Answers

afaik, next.js is prefetching js bundles for the pages linked from the given one. To disable prefetching you can use Link with prefetch={false}:

<Link href="/faq" prefetch={false}>
  <a>FAQ</a>
</Link>

More on this in the docs

like image 161
Evgeny Timoshenko Avatar answered Oct 29 '25 18:10

Evgeny Timoshenko