Skip to content

Instantly share code, notes, and snippets.

@Julien-Marcou
Last active June 16, 2022 11:52
Show Gist options
  • Save Julien-Marcou/8b39502b7637b35aeb376179d0d106d7 to your computer and use it in GitHub Desktop.
Save Julien-Marcou/8b39502b7637b35aeb376179d0d106d7 to your computer and use it in GitHub Desktop.
Zone.js optimization
/* eslint-disable no-underscore-dangle */
(window as ZoneGlobalConfigurations).__Zone_disable_customElements = true;
(window as ZoneGlobalConfigurations).__Zone_disable_canvas = true;
(window as ZoneGlobalConfigurations).__Zone_disable_geolocation = true;
(window as ZoneGlobalConfigurations).__Zone_disable_blocking = true;
(window as ZoneGlobalConfigurations).__Zone_disable_MutationObserver = true;
(window as ZoneGlobalConfigurations).__Zone_disable_FileReader = true;
const disabledEvents: Array<keyof HTMLElementEventMap | keyof WindowEventHandlersEventMap | keyof WebSocketEventMap | keyof XMLHttpRequestEventTargetEventMap> = [
// Scroll
'scroll',
'wheel',
// Mouse
'dblclick',
'mousedown',
'mouseenter',
'mouseleave',
'mousemove',
'mouseout',
'mouseover',
'mouseup',
// Touch
'touchstart',
'touchend',
'touchmove',
'touchcancel',
// Pointer
'pointerover',
'pointerenter',
'pointerdown',
'pointermove',
'pointerup',
'pointercancel',
'pointerout',
'pointerleave',
'gotpointercapture',
'lostpointercapture',
// Drag
'drag',
'dragend',
'dragenter',
'dragleave',
'dragover',
'dragstart',
'drop',
// Animation
'animationcancel',
'animationend',
'animationiteration',
'animationstart',
// Window
'beforeunload',
'unload',
// Other
'resize',
'contextmenu',
];
(window as ZoneGlobalConfigurations).__zone_symbol__PASSIVE_EVENTS = disabledEvents;
(window as ZoneGlobalConfigurations).__zone_symbol__UNPATCHED_EVENTS = disabledEvents;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment