【发布时间】:2021-04-28 20:42:40
【问题描述】:
我一直在测试导致我的灯塔得分低的原因,当我删除以下脚本时,它似乎上升了 30%!我不知道为什么。
这是脚本(smartupp - 一个网络聊天帮助应用)
<script
defer
type="text/javascript"
dangerouslySetInnerHTML={{ __html: `
var _smartsupp = _smartsupp || {};
_smartsupp.key = 'key';
window.smartsupp||(function(d) {
var s,c,o=smartsupp=function(){ o._.push(arguments)};o._=[];
s=d.getElementsByTagName('script')[0];c=d.createElement('script');
c.type='text/javascript';c.charset='utf-8';c.async=true;
c.src='https://www.smartsuppchat.com/loader.js?';s.parentNode.insertBefore(c,s);
})(document);
` }}
/>
我将其包含在页面末尾附近。 当我包含它时,在灯塔分数中它显示“减少未使用的 JavaScript”,我认为是因为 smartupp 包含以下内容:
有人知道为什么这个脚本会大大降低我的性能吗?以及我可以做些什么来改进它。
我正在使用 NextJs (React)。
【问题讨论】:
标签: javascript reactjs next.js smartsupp