Javascript 是否有托管 JSON2 的公开可用的 CDN?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2994577/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 02:50:04  来源:igfitidea点击:

Is there a publicly available CDN that hosts JSON2?

javascriptjsoncdn

提问by Xavi

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

众所周知,GoogleMicrosoft在其 CDN(内容分发网络)上托管了几个常见的 javascript 库。不幸的是,两者似乎都没有托管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.

我知道我可以将 JSON2.js 的副本上传到我的服务器并自己提供服务,但是我想利用 CDN 提供的许多优势。

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?

考虑到这一点,是否有任何公开可用的 CDN 托管 JSON2?如果没有,知道为什么吗?是否有某种版权原因?

采纳答案by Dve

Checkout cdnjs.com

结帐cdnjs.com

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

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

Might also be worth investigating Json3

可能也值得研究Json3

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

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

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

更新:某些信息已过时,已更改为更好的链接。

回答by thorn?

json2.js can be found on Yandex CDN servers.

json2.js 可以在Yandex CDN 服务器上找到。

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

完整版:http: //yandex.st/json2/2011-10-19/json2.js

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

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

HTTPS also works.

HTTPS 也有效。

回答by Andrew

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.

我认为现在期望大型 CDN 开始这样做可能还为时过早。当有足够多的站点使用一个库时,好处就变得很明显:更高的可用性、更频繁的使用、减少客户端请求、提高最终用户的性能。如果只有少数站点在使用它,客户端在其缓存中拥有副本的可能性已经很低,并且所有性能提升都会丢失。所以剩下的就是 MS 和 Google 抵消您的带宽费用,这不是他们的本意。因此,解决方案是让更多的开发人员使用该库。

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.

再加上图书馆太小了。使用保守的缩小,代码仍然只有 3.5KB。作为比较,jQuery 为 24KB,ext-core 为 29KB。我个人建议将库折叠到您自己站点的基础 JS 中,并在那里提高性能。至少在有更广泛的接受之前。

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.

另外,有趣的是我原以为 JSON 库也会托管在 Yahoo,但我找不到它。我的意思是克罗克福德在那里工作。

回答by Thomas Davis

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

来自 cdnjs.com 的 Thomas 有两个简单的原因,为什么没有缩小版本。

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.

1) 使用我们选择的缩小方法,脚本可能无法按作者的意图运行。2) 作为安全步骤,我们确保所有文件校验和与原始作者托管的文件匹配,因此社区提交的更新不能包含格式错误的缩小代码。

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

所以现在让我们托管 Crockfords 托管的未缩小版本; https://github.com/douglascrockford/JSON-js/raw/master/json2.js

回答by DannyLane

There is now.

现在有。

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

Douglas Crockford 最近将 JSON2 放在 github 上,这个url将始终链接到最新版本。

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

编辑:使用这种方法不是一个好主意,请参阅下面的评论。