Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Google Pagespeed FIX does not use passive event listeners warning
// Passive event listeners
// Add this to your own custom.js file < YOU NEED TO CREATE THIS FILE YOURSELF
// Call the file in your body using
// <script src="" ></script>
jQuery.event.special.touchstart={setup:function( _, ns, handle ){this.addEventListener("touchstart", handle, { passive: !ns.includes("noPreventDefault") });}};
jQuery.event.special.touchmove={setup:function( _, ns, handle ){this.addEventListener("touchmove", handle, { passive: !ns.includes("noPreventDefault") });}};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment