I am using hammer for dragging and it is getting choppy when loading other stuff, as this warning message is telling me.
Handling of 'touchstart' input event was delayed for X ms due to main thread being busy. Consider marking event handler as 'passive' to make the page more responsive.
So I tried to add 'passive' to the listener like so
Hammer(element[0]).on("touchstart", function(ev) {
// stuff
}, {
passive: true
});
but I'm still getting this warning.
For those receiving this warning for the first time, it is due to a bleeding edge feature called Passive Event Listeners that has been implemented in browsers over the summer 2016. From https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md:
Passive event listeners are a new feature in the DOM spec that enable developers to opt-in to better scroll performance by eliminating the need for scrolling to block on touch and wheel event listeners. Developers can annotate touch and wheel listeners with {passive: true} to indicate that they will never invoke preventDefault. This feature shipped in Chrome 51, Firefox 49 and landed in WebKit. For full official explanation read more here.
See also: What are passive event listeners?
If you are handling events indirectly via a JavaScript library, you may be at the mercy of that particular library's support for the feature. As of December 2019, it does not look like any of the major libraries have implemented support. Some examples: