javascript - tracing settimeout warnings in angular with zone.js - Stack Overflow

I wrote a library for a third party component provider, which basically adds some new features to one o

I wrote a library for a third party component provider, which basically adds some new features to one of it's components. Everything was fine, performance was fine, all OK. All was written with the default change detection mechanism and with use of zone.js.

Now, I updated both Angular and the third party component to the latest, and I get console warnings like [Violation] 'setTimeout' handler took 537ms and [Violation] Forced reflow while executing JavaScript took 222ms. And the page becomes noticeable slow. Before the updating I also got this kind of warnings, but the delays were like 10 to 50 ms.

Before or after updating, I didn't add any new code to the library. The only changes were the updating to the latest versions. I guess, it must be some internal changes in the third party component.

The question is, how can I trace this warnings? I'm more interested in the setTimeout warning, but also the forced reflow could be interesting.

Thansk.

I wrote a library for a third party component provider, which basically adds some new features to one of it's components. Everything was fine, performance was fine, all OK. All was written with the default change detection mechanism and with use of zone.js.

Now, I updated both Angular and the third party component to the latest, and I get console warnings like [Violation] 'setTimeout' handler took 537ms and [Violation] Forced reflow while executing JavaScript took 222ms. And the page becomes noticeable slow. Before the updating I also got this kind of warnings, but the delays were like 10 to 50 ms.

Before or after updating, I didn't add any new code to the library. The only changes were the updating to the latest versions. I guess, it must be some internal changes in the third party component.

The question is, how can I trace this warnings? I'm more interested in the setTimeout warning, but also the forced reflow could be interesting.

Thansk.

Share Improve this question asked Mar 25 at 19:02 derstaunerderstauner 1,8623 gold badges27 silver badges55 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Check for usage of setTimeout throughout your project.

After identifying, you can try either of these approaches:

  • Comment out all of them and enable them one after another till you find the culprit.

  • Try enabling changeDetection: ChangeDetectionStrategy.OnPush to reduce the number of change detection cycles (Which improves performance). Then call this.changeDetectorRef.detectChanges() to fill in the places where change detection does not fire, which you will observe as bugs in your library.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744174980a4561710.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信