Many libraries and frameworks add non-passive event listeners by default. Not much you can do about it.. Instead of waiting for a support I Would recommend using highly flexible and configurable passive-events-support package to debug and make event listeners passive without touching 3rd party source code.
First, after installing the package debug the touch
and wheel
event listeners and their parameters:
import { passiveSupport } from 'passive-events-support/src/utils'
passiveSupport({ debug: true })
This should console log all the event listeners
[Passive Events Support] Non-passive Event Listener
element: div.some-element
event: 'mousewheel'
handler:
fn: ƒ (e)
fnArgument: 'e'
fnContent: 'console.log(e)'
fnPrevented: false
arguments: false
Notice arguments
parameter, if it is false
, undefined
or object without passive
parameter inside, this event is what causes your browser to throw a warning and is impacting the scroll performance.
To fix it just use the package and logged information to make this exact event listener as passive:
import { passiveSupport } from 'passive-events-support/src/utils'
passiveSupport({
debug: false,
// add this one
listeners: [
{
element: 'div.some-element',
event: 'mousewheel'
}
]
})
Be careful tho, event listeners that call preventDefault()
should not be marked as passive, but to fix the warning should still have passive
parameter with a value of false
instead.
By default the package will check if it is prevented from the handler itself, but in case the event listener is prevented from the method called inside the handler, the package loses track of it. To force assign passive: false
just pass prevented: true
parameter to listeners
item:
passiveSupport({
//...
listeners: [
{
element: 'div.some-element',
event: 'mousewheel',
prevented: true
}
]
})
For me, this package fixed all the warnings cause by materialize and jquery. Hope it helps you too.