简体   繁体   中英

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

加载所有页面

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM