Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitchellkrogza/4298c0c6bdfe31a3ea639d5e30e188b2 to your computer and use it in GitHub Desktop.
Save mitchellkrogza/4298c0c6bdfe31a3ea639d5e30e188b2 to your computer and use it in GitHub Desktop.
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="https://mydomain.com/wp-content/themes/my-child-theme/inc/js/custom.js" ></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