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 trialAnja Karg
6,133 Pointsnormalize.css best way - file or cdn-url
what do you recommend for performance and why?
2 Answers
Luke Glazebrook
13,564 PointsHi Anja!
CDNs and local files are both a great way to import something into your project. CDNs are great because if the user of your website has already loaded the same file from the same CDN on a previous site then it will load in a lot quicker as the browser isn't having to go off and find a file from your server it has never seen before.
However, having a local copy of the file is great because what is the CDN goes down or something happens to that specific URL? This is unlikely to happen but your site would break as a result. This isn't really too much of an issue though because bit CDNs are known for having an incredible amount of uptime and they rarely ever go down.
I guess it really just depends on whether you think it would be beneficial to have it hosted on your server. If not, go for a CDN.
Lin Lu
29,171 PointsIt depends. The benefit of using a CDN is that the CSS or JavaScript file may be cached already in the user's browser, if the user has visited another website that happens to use the same CDN. In that case, using a CDN is faster. However, the downside is that using a CDN requires the Internet access.
Anja Karg
6,133 PointsAnja Karg
6,133 Pointsthanks a lot. is there a way to say "use cdn if possible, otherwise use the local copy"?
Luke Glazebrook
13,564 PointsLuke Glazebrook
13,564 PointsHi Anja!
I'm not 100% on if there is a proper way to do it but you could embed some PHP in your <head> to load the local file if the CDN doesn't respond to a ping. If you wanted to set this up you would have to look into pinging websites/servers in PHP.
I hope I managed to help you out!