1

Here's an example from Bootstrap's "Getting Started" code:

<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/js/bootstrap.min.js"></script>

Putting CSS and JS onto a CDN seems like pure lunacy. If the CDN goes down, so does your site. I gather that pointing to a CDN gives you the programmer the latest updates and all, but what if the maintainers break their own production code? I always download the necessary css and js and park them in my own directory. Whats the consensus?

TL;DR Why leave critical files such as JS and CSS to a CDN?

roguequery
  • 964
  • 13
  • 28
  • Well your "own" CDN can go down too? – Esailija Aug 08 '13 at 16:35
  • 1
    possible duplicate of [Why should I use Google's CDN for jQuery?](http://stackoverflow.com/questions/2180391/why-should-i-use-googles-cdn-for-jquery) - not specific to your bootstrap example, the the answer there gives numerous reasons for CDN usage – MDEV Aug 08 '13 at 16:37

3 Answers3

2

Reliability is stellar for all three CDNs (Google vs. Microsoft vs. Media Temple CDNs)

First off, all three CDNs proved to have excellent availability. The only CDN with any downtime at all for this entire year so far was Microsoft’s, and that was just a few minutes. All three had, when rounded to two decimals, 100.00% uptime.

This really is what you want from a CDN. You shouldn’t have to worry about it working or not, and the distributed nature of a CDN usually makes it extremely reliable, as this survey shows. We will focus the rest of this article on performance since that is where the true differences are.

enter image description here

SOURCE

So the question is. Your host can do better?

daniel__
  • 11,633
  • 15
  • 64
  • 91
  • Ok, that makes ense. But isn't there a significant lag between getting the CSS and JS from a CDN on some distant-ish server versus your own local directory? – roguequery Aug 08 '13 at 16:43
  • @roguequery not even using a CDN at all? Now that's lunacy. Yes it will do *much* better, that's why CDNs even exist. – Esailija Aug 08 '13 at 16:45
  • So by that logic, any public-facing site should be backed against some stack like S3->Cloudfront, rather then, as has been admonished before, keeping a whole site on an S3 bucket. – roguequery Aug 08 '13 at 16:47
  • @loops i made a dupe - simulating discussion none the less – roguequery Aug 08 '13 at 16:49
0

The use of the CDN is to allow for edge caching and improved performance in page loading. Usually you define a fall back reference in the case the CDN is down. Here is another answer that describes this process: How to fallback to local stylesheet (not script) if CDN fails

Community
  • 1
  • 1
dwilson
  • 351
  • 1
  • 5
0

The purpose in pointing to a CDN is decidedly not to stay up-to-date. Generally, and as it appears in your example, you refer to a particular version of an external script. By doing so, you're protected against buggy releases and breaking changes.

The reason you link to the CDN is twofold: You take load off your own servers, so they can spend their time actually rendering dynamic output. And it decreases load times on your site.

See http://developer.yahoo.com/performance/rules.html#cdn

Regarding downtime: A file hosted on a CDN is far more likely to be available than a file hosted on your own network.

svidgen
  • 13,744
  • 4
  • 33
  • 58