Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKen Chung
17,585 PointsIf you use a CDN Link for your project, does it make your site perform faster or slower?
Hi everyone,
Quick question, If you use a CDN Link for your project, does it make your site perform faster or slower? Are local files always better than CDN?
I want to use bootstrap for one of my projects and I don't know if I should download the local files or use a CDN link, I want to know what the best option is, in terms of performance. Thanks.
3 Answers
Sue Dough
35,800 PointsI strongly disagree with Phillip. I think CDN's are a bad idea for the web. The web is still in its infancy and just because something is popular doesn't mean its right. Companies like google that are in bed with the NSA are laughing to the bank that idiot web developers are giving them tons of data mining opportunities for free. CDN's can suck for many reasons:
Your site will have more downtime. For each CDN you add you risk more downtime because you rely on third partys servers. If your server is down the whole site is down. If your server is up and the CDN server is down then you are screwed.
A CDN sucks huge for user privacy. I freaking hate it when sites don't take their users privacy seriously.
A CDN may be blocked in countries like China, Cuba, Iran, Korea or very slow for example google CDN and google fonts makes sites in China a lot slower typically.
If a CDN gets hacked then they can hack your users and distrubute malware.
A CDN can sell your users data since they get the same server logs you do which is tons of data. They can also help your competitors out because ad networks will know who the target user is based on IP addresses.
I have built super fast sites ( faster than most sites out there ) without any CDN's. If your site scales then you can roll your own CDN.
If you do not care about your users privacy and security then use a CDN.
Philip G
14,600 PointsHi Ken, A CDN is often the best option. Like Boonsuen said, it's very likely that it has already been cached at other sites by the visitors browser. Also, a CDN is virtually always faster than your webhost, so for real-world non-local projects, I would go with it.
Best Regards, Philip
Tim Knight
28,888 PointsTo add onto what Boonsuen and Philip have both said about the benefits of a CDN... a CDN also let's your browser pull assets from a different host. In most cases browsers will only have a limited amount of concurrent connections to the same host while downloading your assets. So between your files on your server and the files within the CDN that would be two separate hosts allowing for more connections. Additionally, CDN domains are "cookie-less" which reduces the handshake transaction time between the browser and the CDN cutting off more unnecessary time in the transaction of the files.
Boonsuen Oh
18,788 PointsBoonsuen Oh
18,788 PointsI like to use Google's CDN because it's more likely to be cached on visitor's browser already, therefore faster load. Depending on the situation. And this link to StackOverflow might help you deciding better.