When you encounter "Uses Passive Event Listeners to Improve Scrolling Performance" as a metric to be improved under "Best Practices" on Google Chrome Inspect Audits, add the code below after the opening body tag:
<script type="text/javascript">
jQuery.event.special.touchstart = {
setup: function( _, ns, handle ){
if ( ns.includes("noPreventDefault") ) {
this.addEventListener("touchstart", handle, { passive: false });
} else {
this.addEventListener("touchstart", handle, { passive: true });
}
}
};
</script>
Setting the passive option on your touch and wheel event listeners can improve scrolling performance.
If you are using a DIVI web theme, go to Theme Options, then the "Integration" tab, and add code to the <body> section.
<script type="text/javascript">
jQuery.event.special.touchstart = {
setup: function( _, ns, handle ){
if ( ns.includes("noPreventDefault") ) {
this.addEventListener("touchstart", handle, { passive: false });
} else {
this.addEventListener("touchstart", handle, { passive: true });
}
}
};
</script>
Setting the passive option on your touch and wheel event listeners can improve scrolling performance.
If you are using a DIVI web theme, go to Theme Options, then the "Integration" tab, and add code to the <body> section.
Comments