Better Programming

Advice for programmers.

Follow publication

Member-only story

Stop Importing Whole JavaScript Packages

Aakash Yadav
Better Programming
Published in
4 min readMay 12, 2020

Photo by Pankaj Patel on Unsplash

How many times have you imported a complete package but only need very few features of the features from that package? Probably, a lot.

The most common example of this scenario Lodash. For those of you, who haven’t heard of it, you should check out the documentation.

“Lodash makes JavaScript easier by taking the hassle out of working with arrays, numbers, objects, strings, etc.” — Lodash.com

It has more than 200 functions, which means it really takes out all of the hassle. However, you might end up using only 4-5 in your project, which makes me wonder should I really import the whole package when I’ll only be using 2-3% of the package?

One of my absolute favourite functions is get, which lets you safely access nested objects and also provides default values.

This keeps your code much cleaner and avoids bugs because when you’re expecting an empty array, it won’t return null…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Aakash Yadav
Aakash Yadav

Written by Aakash Yadav

CTO at woobly | Building the Future of Dining | connect with me https://www.linkedin.com/in/aakash-yadav-8a9a6092/

Write a response