javascript – Is there a publicly available CDN that hosts JSON2?-ThrowExceptions

Exception or error:

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?

How to solve:

Checkout cdnjs.com

http://cdnjs.com/libraries/json2/

Might also be worth investigating Json3

http://cdnjs.com/libraries/json3/

UPDATE: Some of the information was out of date, changed to better links.

###

json2.js can be found on Yandex CDN servers.

Full version: http://yandex.st/json2/2011-10-19/json2.js

Minified: http://yandex.st/json2/2011-10-19/json2.min.js

HTTPS also works.

###

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.

###

Thomas from cdnjs.com here with two quick reasons why there is no minified version.

1) The script may not possibly function as the author intended using the method of minification we choose.
2) As a security step we ensure that all files checksums match the original authors hosted files so community submitted updates cannot contain malformed minified code.

So for now that leaves us hosting Crockfords hosted un-minified version;
https://github.com/douglascrockford/JSON-js/raw/master/json2.js

###

There is now.

Douglas Crockford recently put JSON2 on github, this url will always link to the most recent version.

Edit:
Its not a good idea to use this method, see my comment below.

Leave a Reply

Your email address will not be published. Required fields are marked *