不使用被动侦听器来提高滚动性能(灯塔报告) [英] Does not use passive listeners to improve scrolling performance (Lighthouse Report)
本文介绍了不使用被动侦听器来提高滚动性能(灯塔报告)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
最近的灯塔报告标记了以下问题.
A recent Lighthouse Report flagged the following issue.
不使用被动侦听器来提高滚动性能
Does not use passive listeners to improve scrolling performance
它也提到...
请考虑将触摸和滚轮事件侦听器标记为
passive
,以提高页面的滚动性能.
Consider marking your touch and wheel event listeners as
passive
to improve your page's scroll performance.
如何解决此问题?它似乎与jQuery有关.
How do I resolve this issue? It appears to be related to jQuery.
推荐答案
- jQuery无法添加对被动侦听器的支持.
-
预计这是在jQuery 4中添加的(4年后仍在
- jQuery can't add support to passive listeners.
Is expected that this is added in jQuery 4 (4 years and still in
- 5.x)
jQuery.event.special.touchstart = {
setup: function( _, ns, handle ){
this.addEventListener("touchstart", handle, { passive: true });
}
};
这篇关于不使用被动侦听器来提高滚动性能(灯塔报告)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文