I've an Angular 4 project created using @angular/cli
, when running the application in development mode, I receive those warnings in the console:
zone.js:1489 [Violation] 'setTimeout' handler took 209ms
2[Violation] Added non-passive event listener to a scroll-blocking 'mousewheel' event. Consider marking event handler as 'passive' to make the page more responsive.
zone.js:1157 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive.
zone.js:1157 [Violation] Added non-passive event listener to a scroll-blocking 'mousewheel' event. Consider marking event handler as 'passive' to make the page more responsive.
2zone.js:1157 [Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive.
zone.js:1157 [Violation] Added non-passive event listener to a scroll-blocking 'mousewheel' event. Consider marking event handler as 'passive' to make the page more responsive.
zone.js:1157 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive.
zone.js:1157 [Violation] Added non-passive event listener to a scroll-blocking 'mousewheel' event. Consider marking event handler as 'passive' to make the page more responsive.
2zone.js:1157 [Violation] Added non-passive event listener to a scroll-blocking 'wheel' event. Consider marking event handler as 'passive' to make the page more responsive.
zone.js:1157 [Violation] Added non-passive event listener to a scroll-blocking 'mousewheel' event. Consider marking event handler as 'passive' to make the page more responsive.
The weird thing is that warning appear on Chrome only. (my chrome build version is: 58.0.3029.110
)
- What does those (violation) warnings mean?
- Is this harmful to application performance?
- How to disable/override or configure zone.js to remove those warnings?
What is a passive event?
Chrome throws the warning ...
...when you bind to mouse scroll events, to essentially warn that you may have inhibited scroll performance in your event or disabled default events by making a call to
preventDefault()
.Chrome also throws the error when you try and still call
preventDefault()
in a passive event.Firefox has a similar error for this, however does not seem to throw a warning like Chrome:
Warning showcase
Run the following snippet and view the Chrome console in Verbose mode.
Resolving the issue
A similar SO post was made about the implications of this in javascript.
Angular has not yet implemented a generic / ease of use solution for this and can be followed here.
However due to the fact that typescript is compiled to javascript, implementing the above snippet in typescript should still negate the violation.
Performance Impacts
The violation itself is not at all harmful to application performance, however the contents of your event function could be - and thus is why Chrome throws this warning. Note that this warning is only shown in
Verbose console mode
and will not be shown to general users.As far as I am aware, there is no way to disable such warnings as they are generated by Chrome's interpretation of the code at run time.