Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAlex Flores
7,864 PointsQuestion about using libraries and frameworks?
I'm doing the Full Stack JavaScript track and I'm at Express Basic. One thing that I've started thinking to myself is between Express, Node.JS, Angular, CSS frameworks, jQuery, any packages I use on NPM, my project (even if it's a simple portfolio site) is going to be seriously bloated with a lot of code that is mostly not going to be used.
Isn't this going to make whatever I'm working on, drag to a halt?
Is there a way to certain aspects of a library that I want to use? Like Foundation (CSS framework) allows you to download only what you want to use, which is really nice.
1 Answer
Allison Hanna
36,222 PointsTwo answers, ish. One is that yes, you can customize some frameworks to get only what you need, or require only what you need. Like with Bootstrap, you can pick and choose: http://getbootstrap.com/customize/ . And then my second thought is regarding any npm packages you'll require for your project. Your code doesn't really go out with those dependencies, but rather they are merely listed in your package.json file and then when somebody else uses your code they have to install those dependencies themselves. Like if you forked somebody's project on github and cloned it, one of the first things you'd probably do is run npm install
on the command line to download the dependencies.
Also, when you require the scripts for bootstrap or jquery, you can do so via a CDN ( like Google's, https://developers.google.com/speed/libraries/) instead of from your own files. That way a user has most likely already got a cached version from visiting other sites, and it won't need to download from your app.
Alex Flores
7,864 PointsAlex Flores
7,864 PointsThanks for the response, Allison. It still fully make sense to me. Once the contributor or whoever downloads the dependencies and let's just assume they only downloaded the production dependencies, that package (including all of the libraries and frameworks) is still part of the overall website package. I guess, you can take advantage of CDN, but don't most of them charge you to use them?