AngularJS: Parse HTML events in timeline

二次信任 提交于 2020-01-04 15:29:12

问题


During the debugging of my angularjs application, I found a lot of parse html events in the dev tools.

The timeline says that this event is invoked by jQuery.extend.buildFragment and it's hard for me to understand, what directive invokes parse html.

How can I detect, what exactly causes parse html events? Probably the reason could be in the ng-repeat, but I'm not sure.

These events slow down $scope.$apply as well.


回答1:


Every partial html in angular will trigger Parse HTML event, like ng-includes, ng-repeats, directives, and $digest cycles.

Also using jQuery will give you a lot of overhead for initalize jquery instances. jQuery or jQlite buildFragment is called when you or directives or angular call element.html('something tags'), which in turn write to innerHTML which cause parse HTML event in browser and angular walk those children to find more directives and compile those until its complete.

To minimize those, you need to batch process those, but nature of angular will be hard to do directly. May be you can try to use one-time binding syntax :: in angular 1.3+ or make less watchers, so angular won't have to parse html again and again.



来源:https://stackoverflow.com/questions/31697644/angularjs-parse-html-events-in-timeline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!