I am using angular to write an app. Sometimes I forget to remove unused dependencies from a controller. Will it affect the performance in any way?
Note that you cannot inject "providers" into run blocks. The config method accepts a function, which can be injected with "providers" and "constants" as dependencies. Note that you cannot inject "services" or "values" into configuration.
Problems with people Firstly, since the framework is overcomplicated, not many developers really know it well and it is hard to find such developers is very hard. Secondly, server developers won't understand what is going on front-end and won't be able to read the code at all.
Which Component can be Injected as a Dependency In AngularJS? In Angular. JS, dependencies are injected by using an “injectable factory method” or “constructor function”. These components can be injected with “service” and “value” components as dependencies.
It relieves a component from locating the dependency and makes dependencies configurable. It also helps in making components reusable, maintainable and testable. AngularJS provides a supreme Dependency Injection mechanism. It provides following core components which can be injected into each other as dependencies.
It will be extra overhead, but it is very very very minor on the AngularJS side[1]. If your injected dependency does a lot in its constructor (say: load for two seconds) and your unused dependency is the first time it is used, it will affect performance (those two seconds). If the dependency would be loaded later in the application anyway, then it's only a matter of losing two seconds here and gaining two seconds there.
[1]: https://github.com/angular/angular.js/blob/736b6c7fed79c8305786bbb86d39dd7af891a162/src/auto/injector.js#L758 is the code in question. It will have your extraneous dependencies, which will be loaded and then cached. If it was already in the cache (or will be later anyway), the performance hit is very minimal. It is, however, visual clutter in your code!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With