PERF: Disable ember touchstart listener (#15112)

Registering non-passive listeners for the touchstart event can affect scroll performance on mobile devices, and now shows a warning in Chrome. Our current version of Ember unconditionally registers all event listeners, even if they're unused. It also doesn't support passive event listeners. Once we get to Ember 4.0, it lazily registers event listeners, and supports passive listeners via the `{{on` helper.

We already disable the ember `mousemove` and `touchmove` events for performance, so it makes sense to do the same for `touchstart`. We are not using `touchstart` anywhere in core, and I cannot find any official/unofficial plugins which use it. If a `touchstart` event is required, plugins/themes can always register their own listeners (preferably on a specific element, rather than the whole `document`)
This commit is contained in:
David Taylor 2021-11-26 20:22:02 +00:00 committed by GitHub
parent fac6cc0778
commit e8bb37bd89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 2 deletions

View File

@ -5,14 +5,13 @@ export default {
initialize() {
// By default Ember listens to too many events. This tells it the only events
// we're interested in. (it removes mousemove and touchmove)
// we're interested in. (it removes mousemove, touchstart and touchmove)
if (initializedOnce) {
return;
}
Ember.EventDispatcher.reopen({
events: {
touchstart: "touchStart",
touchend: "touchEnd",
touchcancel: "touchCancel",
keydown: "keyDown",