Ask HN: CDN or npm?

2 points by redxblood ↗ HN
Simple question: Suppose i'm going to use bootstrap, and I have to include it in my project.

It doesn't make any difference to me whether to use a cdn or npm.

Which should I use in your opinion?

1 comment

[ 0.19 ms ] story [ 9.5 ms ] thread
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/

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