angularjs - Angular view performance related to ng-app/ng-controller placement in DOM -


i wondering whether gain significant performance difference in angular app (specifically view processing) if change ng-app , ng-controller attribute placement i.e. body inner-page block element smaller dom subtree?

suppose have long page huge amount of content, part of angular powered. else either server generated means it's static client-side pov.

would better put ng-app/ng-controller on subnode angular executes or same if put them on body element of long page?

does angular process view of sub-dom ng-app/ng-controller defined or process whole dom anyway?

is there proof or angular documentation?

theoretically/potentially? yes, new dev mentions, bootstrap function have larger dom run compile on, take longer compiling smaller tree.

practically? not. best bet benchmark own page.

as experiment, can try following. generated simple random dom , injected jsfiddle console.time starting @ script load, , ending when controller ready. there's small sub-tree beside (as sibling) larger, 5000-node tree.

here's fiddle wrapping entire body: http://jsfiddle.net/gruagq8d/

and here's fiddle small subset used: http://jsfiddle.net/h0hod2j8/

for me, running either of fiddles repeatedly converges on 260ms.

i've tried running similar code on real webpage sources, such stackoverflow itself, , found same results (however did not publish of these because publishing other people's real pages jsfiddle not feel proper without permission) - can try pretty trivially.

admittedly, doesn't follow great benchmarking methodology, if wrapping lots of additional dom nodes caused significant different performance i'd still expect @ least some difference in these.

i don't think additional compile time issue; small doms it's fast, , large dom relevant compared time takes browser build dom in first place.

all said, mentioned before, best option try run similar benchmarks own page.

edit: modifying same benchmark test digest cycles shows there's no significant difference in well:

wrapping minimal: http://jsfiddle.net/fsyfn1ee/

wrapping whole dom: http://jsfiddle.net/04tdwxhp/


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -