44

Recently Chrome started emitting the following warnings:

[Violation] Added non-passive event listener to a scroll-blocking 'touchmove' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952

These are coming from the JavaScript Google Maps API code. I'm able to add {passive: true} to addEventListener() in my own code but don't know how to suppress the warning in Googles libraries?

Kevin Reid
  • 37,492
  • 13
  • 80
  • 108
  • So you are saying that Chrome wasn't showing these messages before? So you think that an update changed things? Or do you think an update to the Maps API changed? – Abraham Luna Apr 09 '18 at 14:02
  • Hello, Did you fix this? I am facing same issue. Thx – Philippe Corrèges Oct 02 '19 at 14:18
  • I am facing the same issue, and it is really weird that the google maps api doesn't integrate the passive property. Any solution? – el3ati2 Nov 02 '19 at 02:18
  • I am facing same issue. It is surprising to me that this question hasn't been answered yet. Any solution from anyone? – russell Jul 23 '20 at 03:06

2 Answers2

1

this works for me. Got here https://stackoverflow.com/a/55388961/2233069

(function () {
    if (typeof EventTarget !== "undefined") {
        let func = EventTarget.prototype.addEventListener;
        EventTarget.prototype.addEventListener = function (type, fn, capture) {
            this.func = func;
            if(typeof capture !== "boolean"){
                capture = capture || {};
                capture.passive = false;
            }
            this.func(type, fn, capture);
        };
    };
}());
djdance
  • 3,110
  • 27
  • 33
0

There is nothing you can do at this point. It's a warning that is generated from Googles own API code. As long as your own event listeners are passive, I think it can be safely ignored.

bytes4me
  • 11
  • 3
  • You will also notice that none of the examples shown in Googles own Maps API documentation for event listeners are using passive event listeners. – bytes4me Feb 02 '21 at 03:59