Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Added non-passive event listener to a scroll-blocking 'touchstart' event

Suddenly today, out of nowhere, I started getting this one on every page on our website

Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive 

And its not just once or twice.. its like thousands of them....

enter image description here

They are running amok.

The only way to stop the flood of violations is to comment out this line

  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js" type="text/javascript"></script> 

I read the other posts on what this violation means, but I really cannot see that I did anything different between two hours ago and now (I did a full rollback just to see if it helped)

It's almost like someone put a bug into jquery.min.js but I seriously doubt that, because then everyone would get it.

Any ideas? I tried debugging everything I could and I still have no idea what causes this?!?

UPDATE

I replaced all <button><md-tooltip>text</md-tooltip></button> with <button data-toggle="tooltip" title="text"></button> This removed 99% of all the violations.

like image 711
torbenrudgaard Avatar asked Sep 07 '17 11:09

torbenrudgaard


People also ask

How do you fix does not use passive listeners to improve scrolling performance?

To fix this audit, add a passive: true flag to every event listener flagged by GTmetrix. For example, document. addEventListener('touchstart', onTouchStart, {passive: true});

How do you make an event handler passive?

Consider marking event handler as 'passive' to make the page more responsive. Hammer(element[0]). on("touchstart", function(ev) { // stuff }, { passive: true });

What are passive event listeners?

Passive event listeners are an emerging web standard, new feature shipped in Chrome 51 that provide a major potential boost to scroll performance. Chrome Release Notes. It enables developers to opt-in to better scroll performance by eliminating the need for scrolling to block on touch and wheel event listeners.

What is wheel event listeners on the root Iphone?

Touch and wheel event listeners are useful for tracking user interactions and creating custom scrolling experiences, but they can also delay page scrolling.


1 Answers

This solve the problem to me:

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 });     }   } }; 
like image 154
Sergio Avatar answered Sep 16 '22 14:09

Sergio