3 ms·
Be careful loading JS from sites you don't control. If the host goes down, your search stops working. If the host becomes malicious or compromised, your site be
by jstanley 9y ago
Be careful loading JS from sites you don't control. If the host goes down, your search stops working. If the host becomes malicious or compromised, your site becomes malicious or compromised.
For best results, host the JS yourself.
- 52-6F-62 9y agoAgreed. It might not always be the most performant option, but it's reliable. I only use CDNs in dev environments, for quick tests, or for non-public facing minor temporary projects. If they go permanent I switch to serving the libraries locally. More often than not when I am dealing with a CDN in these situations, it's from CDNjs alone -- if I can't get it from them, I take the extra few minutes to serve it. I'll either serve each library separately, bundled, or bundled with my own client code. at least until es6 modules are ubiquitous. In enterprise situations, it's a little different. I work for a company that pays Akamai a significant sum to make sure all of that's sorted out for anything large. Custom client code usually is served locally -- depending on the project.
- leeoniya 9y agoit always baffles me how nonchalantly devs will inject third-party js without researching smaller/faster/more secure self-hosted solutions. even social sharing widgets are easily replaced [1]. meanwhile, everyone loses their shit over the obvious implications [2]. this applies to using CDNs for everything, too. [1] https://github.com/heiseonline/shariff https://github.com/heiseonline/shariff [2] https://www.theguardian.com/technology/2017/jul/03/facebook-track-browsing-history-california-lawsuit https://www.theguardian.com/technology/2017/jul/03/facebook-...
- tedmiston 9y agoThe latter is a solved problem with SRI which most CDNs support. https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity https://developer.mozilla.org/en-US/docs/Web/Security/Subres...
- Franciscouzo 9y agoSRI is not a matter of servers/CDNs to support, it's run completely on the browser. I'd argue it's not a bulletproof solution, since only ~60% of browsers support it (https://caniuse.com/#feat=subresource-integrity https://caniuse.com/#feat=subresource-integrity).
- tedmiston 9y agoThanks for sharing. It looks like the active major browsers that don't support it in their latest version are Edge and Mobile Safari. I wonder why they haven't done so yet.