23 ms·
There are quite a few disadvantages to using a CDN like Google. - Delay for DNS resolution and the new TCP connection could be non-trivial (some tests show 300
by rapind 11y ago
There are quite a few disadvantages to using a CDN like Google.
- Delay for DNS resolution and the new TCP connection could be non-trivial (some tests show 300ms+).
- A JS CDN is also likely tracking your traffic and you may not want them to.
- No offline dev environment (on the plane).
- Server run (phantom etc.) tests might run super slow if they have to pull in a remote js library.
- Probably issues when it comes to apps that are meant to work offline, although I think this is solved with service workers proxying the CDN request.
And if the recommendation is to continue loading large libraries from a CDN and nevermind only what you need, well there's still a memory cost. If I have 5+ SPAs running in tabs that are each fairly complex (you know, like Gmail), it does start to add up. Because of the way that tabs are sandboxed I believe this may mean 5 copies of jQuery or React or Angular or w/e.
- SapphireSun 11y agoI've also encountered problems with China blocking jQuery or fonts from Google.
- Grue3 11y agoThis is solvable by also hosting a local copy and load it if CDN is not available. Example (from my website): <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script>window.jQuery || document.write('<script src="/js/vendor/jquery-1.10.2.min.js"><\/script>')</script>
- mateo411 11y agoIt's possible to not use the CDN when you are developing in your local environment, and use the CDN in your production environment. That way you can keep developing even when you are on an airplane.
- edejong 11y agoPlus the cost of parsing the JSON and merging the huge object structures these libraries provide. I missed one item on your list, which is security. Google does not provide any guarantees on the safety of the CDN provider versions of JQuery. Imagine the mayhem when a widely used jquery library is replaced by a backdoored version.
- acdha 11y agoYour last point is correct but only for a limited time now that there's a standard for putting strong hashes on CDN resources: http://caniuse.com/#feat=subresource-integrity http://caniuse.com/#feat=subresource-integrity