TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: CDN or npm?

2 点作者 redxblood超过 8 年前
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?

1 comment

niftich超过 8 年前
CDN. There&#x27;s a higher likelihood that a user of your site would have it cached, considering how popular Bootstrap is, and if it doesn&#x27;t bother you that you&#x27;re serving traffic through and directing users to a third-party.<p>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&#x27;s unlikely to change, and not, say, &#x27;bootstrap-latest.css&#x27;.<p>[1] <a href="https:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;2016&#x2F;REC-SRI-20160623&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;2016&#x2F;REC-SRI-20160623&#x2F;</a><p>[2] <a href="https:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;2016&#x2F;REC-SRI-20160623&#x2F;#use-casesexamples" rel="nofollow">https:&#x2F;&#x2F;www.w3.org&#x2F;TR&#x2F;2016&#x2F;REC-SRI-20160623&#x2F;#use-casesexampl...</a>