Search code examples
npmpackagecdn

Angular newbie question regarding packages install


I make this question because of a problem I'm having making "bootstrap-select" to work with Bootstrap 4, but its a rather general conceptual question. Let's go:

What's the difference between installing a package and just referencing its css/js in html? Let's take bootstrap-select as an example:

I can put the references I paste below inside index.html and bootstrap-select will work (or at least it should) but I can also install package with "npm install bootstrap-select" so what's really the difference between both approaches? It is one of them just enough for make the package to work? Are both steps required? What's a best practice?

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/css/bootstrap-select.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.2/js/bootstrap-select.js" />

Another example, documentation says bootstrap-select requires Popper so it's enough to add this next script reference to index.html or instead I should install popper through npm install popper? Or I should do both?

<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" />

Solution

  • According to me, the best practice is to install and get into node_module. my reason for that would be

    1. You need to be connected to the internet while loading the application (Package won't load when you're running in intraNet.

    2. You might never know when would the package CND is updated and you might face some issues after updates.

    Feel free to correct me :)