Does not use passive listeners to improve scrolling performance from materialize-1.0.0.min.js

527 views Asked by At

Consider marking your touch and wheel event listeners as `passive` to improve your page's scroll performance.

How to fix "Does not use passive listeners to improve scrolling performance" error in materialize-1.0.0.min.js.

I added following Jquery but pbm not solved

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") });
    }
};
1

There are 1 answers

0
Ignas Damunskis On

Are you sure it’s jquery that’s giving you this warning?

Import not minified materialize script and see what part of code is warning you.

You might need a general fix for it, not only jquery. This light package fixed the issue for me.

$ npm install default-passive-events

// index.js
import 'default-passive-events'
// if no bundler used, just import the script:
// <script type="text/javascript" src="node_modules/default-passive-events/dist/index.js"></script>