tags:

views:

352

answers:

3

It's well known that Google and Microsoft host several common javascript libraries on their CDNs (content distribution networks). Unfortunately neither seems to host JSON2.js.

I'm aware that I could upload a copy of JSON2.js to my server and serve it myself, but there are a number advantages CDNs offer that I would like to take advantage of.

So with that in mind, are there any publicly available CDNs that host JSON2? If not, any idea why? Is there some sort of copyright reason?

A: 

For one thing, I had never heard of JSON2, and don't find a ton of references to it when searching. Sounds like it's just not popular enough. Use your own resources - sorry!

Matchu
It's Crockford's current implementation here: http://www.JSON.org/json2.js
quixoto
@quixoto - yeah, I'm slowly figuring it out. I was aware of that library, but had never heard of it referred to as JSON2. Mainly because I usually end up using jQuery, which has a JSON parser built in.
Matchu
chrome and firefox (at least) support the `JSON.parse` and `JSON.stringify` methods natively
Jason
BTW, IE8 also supports `JSON.parse` and `JSON.strinigfy`.
Xavi
+4  A: 

I think probably it's too early to expect the big CDNs to start doing this. When enough sites are using a library, the benefits become clear: greater availability, more frequent use, reduced client requests, increased performance for the end user. If only a few sites are using it, chances of client having a copy in their cache already is low and all performance boosts are lost. So all that's left is that MS and Google offset your bandwidth charges, which is not their intention. Thus, the solution is to get more developers to use the library.

Plus the library is so tiny. The code is still only 3.5KB using conservative minification. For comparison, jQuery is 24KB and ext-core is 29KB. I'd personally recommend folding the library into your own site's base JS and get your performance boost there. At least until there's wider acceptance.

Plus, it's funny I'd have expected the JSON library to be hosted also at Yahoo, but I can't find it. I mean Crockford works there.

Andrew
Those are fair points. The `JSON` object is becoming standard in many browsers so the need for `JSON2.js` declining. Also the library is tiny! It's just that I've gotten into the habit of creating small self-contained JS apps that I can quickly upload or e-mail to people. Every now and I end up using the `JSON` object. In those cases my JS app either doesn't work in IE6/7 or it's no longer self-contained. =(
Xavi