Has anyone implemented Underscore or Lodash into their existing AngularJS project for a performance boost? If so:
I have not actually played with Lodash before and was looking into learning it. But I typically like to learn something and then actually use it shortly after, so that the concepts stick better. If I'll get some good benefits out of implementing Lodash, then I think it would be a good time to learn it now.
I do typically need to perform functions such as filtering or finding an object inside some sort of collection, so I'm thinking that's where I would utilize it the most.
But the downside of using lodash in an application is that it increases the size of the application which in turn affects the performance of such applications.
But Sometimes You Do Need Lodash Not every Lodash utility is available in Vanilla JavaScript. You can't deep clone an object, for example. That's why these libraries are far from obsolete. But if you're loading the entire library just to use a couple of methods, that's not the best way to use the library.
And thus, you start using the methods that are equally easily available inside the JS itself. And this brings us to the next thing, which is performance. Lodash is extremely well-optimized as far as modern JS goes, but, as you may know, nothing can be faster than native implementation.
Well they have really different purposes.
Angular is to build an application. It helps you to structure your code and separate responsibilities between your components (modules, controllers, services, directives, routers).
Lodash is nice to manipulate collections, arrays, objects, strings, etc. It helps your code to be shorter, cleaner and probably faster. It is really well tested and documented. In my opinion, it makes your job simpler.
I use Lodash for 4 years now. I found it useful in all my projects (Backbone, Angular, JavaScript, node, in the unit tests, in the build configuration files (Grunt, Gulp, Webpack)).
PS: Lodash is also a must-have to go into functional programming in JavaScript.
Edit: Example of searching that you can't easily achieve without Lodash
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