Skip to content

Instantly share code, notes, and snippets.

@danfoust
Created December 20, 2018 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danfoust/ced2e6495165be6b64d165ad3753f087 to your computer and use it in GitHub Desktop.
Save danfoust/ced2e6495165be6b64d165ad3753f087 to your computer and use it in GitHub Desktop.
Improves scroll performance by making jQuery events passive. Run directly after jQuery script is loaded. Read more: https://stackoverflow.com/questions/46094912/added-non-passive-event-listener-to-a-scroll-blocking-touchstart-event
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 });
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment