Elyas Pourmotazedy
Elyas Pourmotazedy

Reputation: 732

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

Upvotes: 4

Views: 4311

Answers (1)

Evgeny Timoshenko
Evgeny Timoshenko

Reputation: 3259

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

Upvotes: 7

Related Questions