Difference between package managers, cdns, and normal includes

Viewed 1165

I am wondering what's the difference between these 3 ways of including third party code in a project. For example, in bootstrap, I can include the css and javascript with a cdn link, or download the minified versions and include them in the project or install bootstap with a package manager in the directory of my project. I understand that the cdn is not good because maybe there will be a version change and still have the old version's code and it needs internet connection in order to work. But what's the difference between installing bootstrap with a package manager and just download the min versions and include them?

2 Answers

Some quick comparison points:

  • If you are not connected to the internet, your NPM package will still work. Your CDN link will not.

  • CDN usually only hosts the most popular stuff. If you want to use a less popular package, you'll want to use NPM.

  • Updating NPM packages is easier, especially since some forms will look for major/minor updates. You'd have to change your CDN link by hand.

There is no real difference. What happens with a package manager is that it puts it in a pre-specified directory in your project. That package may include easy ways of including it easier like bundling, but in the end, a package for something like bootstrap just goes and gets the files and puts them in your project. No different than you doing it yourself.

Related