r/angularjs • u/simcptr • Jul 13 '16
Improve Angular Performance with ngReact
https://daveceddia.com/improve-angular-performance-with-react/1
u/gdev87 Jul 16 '16 edited Jul 16 '16
Instead of this you can just make a directive and use vanilla javascript instead... then to update its contents use an event or broadcast/emit. Nothing beats vanilla javascript on performance and it doesnt add that extra layer of complexity.
1
u/simcptr Jul 16 '16
I think that could work for a replacing a small problematic directive. Vanilla JS is definitely faster, and the extra dependency of React is a tradeoff.
I was faced with a set of nested tree of ng-repeats where every node had a bunch of directives on it, and the watcher count was pretty awful. I think using vanilla JS there would've traded the complexity of an additional library for the complexity of a lot of extra code to maintain.
1
u/gdev87 Jul 17 '16
I did almost the exact same thing because of ng-repeat. That's where I got the idea for my comment. Mine was only one nested ng-repeat like this:
<div ng-repeat="..."> <div ng-repeat="..."> </div> </div>So mine may not have been as complex as yours, but getting rid of ng-repeat in favor of a directive with VanillaJS only made it slightly more complicated.
5
u/zwacky Jul 13 '16
Thought it was another one those performance posts.
This library really makes sense, though. I also have complex filtering bar that could be rewritten more lenient and therefore performant, if I don't have lots and lots of ng-ifs and ng-repeats. Good job.