简体   繁体   English

为什么nextjs在我构建时在第一次加载时加载所有页面

[英]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.我正在为我的新网站使用 nextJS,但网站的 SEO 和速度对我来说非常重要。 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. afaik,next.js 正在为从给定页面链接的页面预取 js 包。 To disable prefetching you can use Link with prefetch={false} :要禁用预取,您可以将Linkprefetch={false}

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

More on this in the docs更多关于这方面的信息在文档中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 首次加载页面时未定义 firebase 和 nextjs 的 useEffect - useEffect with firebase and nextjs undefined when page first loads 在第一次加载 nextjs 时无法加载所有内容/图像 - Can not load all content/images at first load nextjs 如何在屏幕加载时首先加载模态 - How to load modal first when screen loads 为什么我在第一次加载时在 nextjs 中没有得到任何东西(getInitialProps 中的 css 和 params) - why i dont get nothing in nextjs in first load (css and params in getInitialProps) 为什么发布到 GitHub Pages 时,NextJS 中不呈现 public/image? - Why public/image is not rendered in NextJS when published to GitHub Pages? 如何在加载时为 Nextjs/Image 添加淡入 animation? - How can I add a fade-in animation for Nextjs/Image when it loads? NextJS 减少共享 JS 的首次加载 - NextJS reduce First Load of shared JS NextJS,使用链接钩子访问站点时,useSWR 钩子在第一次加载时获取未定义的值 - NextJS, useSWR hook gets undefined values on first load when accesing site with Link hook NextJS官方示例代码:_app.getInitialProps调用Component.getInitialProps-这是为了确保所有页面都加载数据? - NextJS official sample code: _app.getInitialProps calls Component.getInitialProps — is this to make sure all pages load data? NextJS 和 Redux 更改页面时清除存储 - NextJS and Redux clearing store when changing pages
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM