Why You Shouldn't Self-Host Your Assets
Date published: June 4th 2019
Harry Roberts put out an article out why you should self-host your static assets, I agree with some of his points but I also disagree with some of them. Please read his article before you read this.
When you use a CDN (such as code.jquery.com or jsdelivr.com) it takes whatever you are pointing to and moves it off your own server and let's another company handle it who has more servers (around the world) and more expertise.
Use the right CDN provider
While there may be some slowdowns if you are a CDN, you may not have the right CDN provider. There are so many CDN providers you just have to find the one that fits both you and your customers. There is always outages, no matter if you self-host it or put it on a CDN, nothing is 100% online.
Services can always be shut down (and without notice) but that is why you should use a CDN provider that has a good reputation, and have a backup so you can easily switch CDN providers if you need to.
By using a CDN your website may be available in parts of the world that it wasn't previously. Even if it's some text, it's better than your site as a whole not being available.
If you don't use a CDN behind your own website then it means that every time someone visits your website the computer have to go to where your server is located (which could be on the other side of the world) and get the content then come back to display it for you. But if you use a CDN then your content will most likely view faster since the visitor will go the nearest CDN network spot and get the content from there. It isn't always faster as sometimes some closest network spots can be very far away. So you want to choose a CDN provider that have tons of spots close to where your target audience (and readers) will come from.
Security Vulnerabilities - It will happen to anyone
There will always be security vulnerabilities, even if you self-host them you could have a vulnerability. If you don't want someone to know about it then it shouldn't be online. SRI (subresource integrity) then help to ensure that something isn't changed. While about 90% of all browsers do accept and use SRI there are still browsers that don't accept SRI so you can't be 100% sure that everyone will use SRI.
Use multiple CDN providers - to ensure downtime is kept to a minimum
You should use multiple CDN's, if something goes down in one company then your entire website doesn't go down. You may think that it means you will have to pay more, but there are plenty of free CDN providers. Most of the time free means that you are the product but that isn't always the case. Some free CDN's include: Cloudflare, Amazon AWS has a free tier, Cloudinary (referral link), jsDelivr, and GitCDN are just some free CDN providers.
Using a CDN means faster for all websites
Sometimes it seems like a website will take longer to load when using a CDN, it won't always. If you point to the same version of jquery (and same CDN provider) that another website is using then it's faster for the user. It may not be faster for you, but we want to speed up the web and by doing a little bit we can speed up everyone's visiting experience.
Caching - It's a good thing
Sometimes caching is a good thing, it may take longer on the first time for your website to load and it may look like your website never changes. But it means that when someone visits your website again they can more quickly load the website and if you set the cache of the actual content low enough then the visitor can easily see the new content. You can set the cache to be higher for your CSS or something that will rarely changes to quickly load it.
A CDN may not be the solution - but self-hosting isn't the best thing
Yes there are times when you should self-host but overall using a CDN to speed up your own site and the entire web in general (especially if multiple websites use the same CDN and point to exactly the same version). Using a CDN is not just about website performance it's about speeding up the entire web. There is a fine balance between self-hosting everything and using a CDN, it's probably better to use a mix of both and this all depends on your own needs.
Seize the day. This whole site is under UNLICENSE / CC0 for you to create, learn from, make money from, or anything like that.