Search code examples
javascriptangularweb-applicationsangular2-changedetection

Long idle time on event clicks on Angular webapp


I have an Angular10 web application. While analyzing the performance with DevTools I noticed that the click event takes quite a long time, most of it is spent doing nothing, then a globalZoneAwareCallback is called followed by a microtask

Here's a snapshot of the flame chart. When the user clicks on a button, the task takes several milliseconds (in this case 107ms) but most of the time is spent doing nothing.

Is this expected or there's something I'm missing? I do use the default change detection strategy.

Is that an idle time or is the app doing something really time consuming?

enter image description here

EDIT

I found out that only the first time the event takes quite a significant bit of time (some initialization going on?). Subsequent events are in a reasonable range (40ms-50ms).


Solution

  • Initialization or some other operations done by Angular. Subsequent events don't show the problem