NextJS-改进“总阻塞时间”在Google PagesPeed上
I'm using NextJS and i'm pretty new on that. I'm trying to increase my ranking on Google Pagespeed, and i already did some good progress on that.
As you guys can see on the screenshot, the only bad metric is the "Total Blocking Time":
现在,我已经用完了如何使该方法更好的选择,我正在动态导入组件,删除未使用的JS,我正在使用NextJS最佳实践。
我非常感谢你们可能会
提前感谢的任何帮助
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因此,让我们从 tbt
如何提高TBT分数
您需要从a lighthouse绩效审核
因此,如果您发现某些动作不需要您延迟它。最常见的是:
例如,您在页脚或孔页脚上有一些元素。您可以将
JavaScript
和CSS
拆分,并动态加载该部分。您可以使用 noreferrer“> intersectionObsererver //caniuse.com/intersectionObserver“ rel =“ noreferrer”>支持因为这已经足够好了,但是如果不支持,这是一个很好的做法:
示例代码( )在Vanilla JavaScript 中):
您可以阅读更多有关
So lets start from what is TBT as the docs says
How to improve your TBT score
You need to start with a Lighthouse performance audit
So if you find some action that aren't necessary you need to delay it. Most common are :
For example you have some element in the footer or the hole footer it self. You can split your
javascript
andcss
and loaded that part dynamically.You can use IntersectionObserver , the support for that is good enough, but it's allways a good practice to ensure if not supported:
Example code (in vanilla javascript):
You can read more about rootMargin
实际上,动态渲染一切都是不良的做法,因此表现不佳。您将需要动态导入组件,该组件在第一个构建时间,例如页脚或聊天框。
Actually, dynamically render everything is an bad practice, hence more bad performance. You will want to dynamic import component that doesnt include in the first build time, for example, a footer or chatbox.