5 ms·
Is there a good reason to use these things hosted by a third party source? Libraries are tiny, the fonts can be downloaded from Google Fonts and embedded locall
by ocdtrekkie 9y ago
Is there a good reason to use these things hosted by a third party source? Libraries are tiny, the fonts can be downloaded from Google Fonts and embedded locally, etc. Even the Google Analytics JS script I presume can be stored and run local.
Shouldn't a goal be to mitigate the number of possible failures which can bring down your site by reducing the number of single points of failure?
- sbov 9y agoIIRC Google Fonts aren't easy to download because they vary by user agent.
- vetinari 9y agoYou can download zip archive of ttfs using the customize tab on the fonts site. Or go directly to the source, and get the git repo.
- wil421 9y agoOne reason is that by linking to external libraries your browser most likely has them cached. At least it was the case a few years ago when I was doing web dev.
- eric_b 9y agoI see this argument a lot but I don't think it's necessarily a good one. If a third party CDN goes down, your site is down. A few extra ms in initial download isn't so bad compared to having your site be completely inaccessible for reasons outside your control.
- jlgaddis 9y agoThen why are these sites down?
- wil421 9y agoSelf hosting will probably cause more downtime than if you are using a decent CDN. CDN is just one of many points of failure, I would expect there's a fine balancing act where you could achieve benefits of both.
- dom0 9y agoBy definition, if your site is down, you don't need your assets.
- deleted 9y ago[deleted]
- omni 9y agoWhy doesn't having the resources cached provide a buffer against short-term outages of the CDN?
- nleach 9y agoThe browser still has to make a request to the CDN to get back an HTTP 304. The goal is to avoid downloading a potentially large payload, not be resilient against connectivity issues.
- hobofan 9y agoBecause normal Cache-Control is only aimed at reducing the amount of data transferred. With newer immutable Cache-Control[0], a CDN going down wouldn't have an effect if you have the resources cached. [0]: https://hacks.mozilla.org/2017/01/using-immutable-caching-to-speed-up-the-web/ https://hacks.mozilla.org/2017/01/using-immutable-caching-to...
- matthberg 9y agoWhen a CDN goes down, that is the time to use local backups. The best policy I've seen is using 3rd party CDNs for scripts like jQuery, ie. common, unchanging resources, yet with subresource integrity checks [0] to make sure it's actually what you are asking for (in case the site somehow gets compromised or returns an error). On top of that to cover for failure, you have a fallback locally hosted copy which is loaded only if the CDN version fails. [0] https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity https://developer.mozilla.org/en-US/docs/Web/Security/Subres...
- wil421 9y agoWould those resource checks been done at the client or sever? For example the sever pings the CDN at a set interval and if it's down the sites code is modified to included links to local copies. Or would you do something in the browser to fetch the local one in case of failure?
- Asmod4n 9y agoThis is most likely never the case, because there are way too many versions of each library.
- deleted 9y ago[deleted]
- bcherny 9y ago2 reasons: 1. If you're still using HTTP 1.x, sharding assets across origins lets the browser load them in parallel (if set up correctly). You can generally load just 6 assets in parallel per origin, and sharding is a way to get around that limit. 2. A library like jQuery is so popular, and is so often served from googles CDN, that chances are a user already has it in their local cache from when they downloaded it on some other site. That said, yes - the downside is more surface area that might go down.
- dchest 9y ago2. A library like jQuery is so popular, and is so often served from googles CDN, that chances are a user already has it in their local cache from when they downloaded it on some other site. Which of these versions do you have cached? 3.2.1, 3.2.0, 3.1.1, 3.1.0, 3.0.0, 2.2.4, 2.2.3, 2.2.2, 2.2.1, 2.2.0, 2.1.4, 2.1.3, 2.1.1, 2.1.0, 2.0.3, 2.0.2, 2.0.1, 2.0.0, 1.12.4, 1.12.3, 1.12.2, 1.12.1, 1.12.0, 1.11.3, 1.11.2, 1.11.1, 1.11.0, 1.10.2, 1.10.1, 1.10.0, 1.9.1, 1.9.0, 1.8.3, 1.8.2, 1.8.1, 1.8.0, 1.7.2, 1.7.1, 1.7.0, 1.6.4, 1.6.3, 1.6.2, 1.6.1, 1.6.0, 1.5.2, 1.5.1, 1.5.0, 1.4.4, 1.4.3, 1.4.2, 1.4.1, 1.4.0, 1.3.2, 1.3.1, 1.3.0, 1.2.6, 1.2.3
- castis 9y agoAsking an annoyed rhetorical question doesn't seem productive to the point you're trying to make here. As an actual answer, it would be variable proportional to the size of the window between releases mentioned here: https://en.wikipedia.org/wiki/JQuery#Release_history https://en.wikipedia.org/wiki/JQuery#Release_history I'm sure a fair amount of people serve jQuery from a local storage. The usefulness that the user might already have it cached is a non-zero point, no matter how insignificant you may think it is.
- kerkeslager 9y agoHow many do you need to make this worthwhile? The ratio of cost of storing a library versus the cost of GETing a library is very low, so the chances of already having a library cached can be very low for the EV to be worthwhile. Weighing that against the chance of downtime is a bit more complicated, admittedly.
- jjlane 9y agoOur GA is setup through GTM now, that is why it's not hardcoded into our head. Really the most important gain we get from hosted libraries is caching. Since any user that has hit a google hosted lib, which is pretty widely used and distributed it allows them to access their cached version instead of sending our another request.
- tregoning 9y agoYes, Google can change the logic for auth, analytics, etc at any time and your local outdated copy will be useless, further I believe it's possible that Google returns different JS depending on the browser that's requesting it in order to keep payloads down and performance high.