
Ask HN: CDN or npm? - redxblood
Simple question: Suppose i&#x27;m going to use bootstrap, and I have to include it in my project.<p>It doesn&#x27;t make any difference to me whether to use a cdn or npm.<p>Which should I use in your opinion?
======
niftich
CDN. There's a higher likelihood that a user of your site would have it
cached, considering how popular Bootstrap is, and if it doesn't bother you
that you're serving traffic through and directing users to a third-party.

Consider using Subresource Integrity [1][2] to pin a particular checksum to
the particular version served from the CDN, for some extra assurance that the
CDN is delivering correct file. This, of course, only works if you link to a
static file that's unlikely to change, and not, say, 'bootstrap-latest.css'.

[1] [https://www.w3.org/TR/2016/REC-
SRI-20160623/](https://www.w3.org/TR/2016/REC-SRI-20160623/)

[2] [https://www.w3.org/TR/2016/REC-SRI-20160623/#use-
casesexampl...](https://www.w3.org/TR/2016/REC-SRI-20160623/#use-
casesexamples)

