如何在像 google 这样的快速免费 CDN 上托管您自己的 JavaScript 脚本文件(Jquery 除外)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4923253/
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
How to host your own JavaScript scripts files (other than Jquery) on a fast & free CDN like google?
提问by Sam
Dave Wardinspired me to host my javascript jquery externally on google CDN:
Dave Ward启发我在 google CDN 上外部托管我的 javascript jquery:
//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js
//ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js
Now, can I host my other/own (non-JQuery) JavaScripts on free CDNs like google?
Is this possible? Or only for Jquery/famous often used scripts only?
现在,我可以在像 google 这样的免费 CDN 上托管我的其他/自己的(非 JQuery)JavaScript 吗?
这可能吗?还是仅适用于 Jquery/著名的常用脚本?
Thanks for your suggestions.
感谢您的建议。
回答by user1866612
I'm using http://yourjavascript.comfor 3 years and happy with their free service.
我使用http://yourjavascript.com3 年了,对他们的免费服务很满意。
回答by Alex T
codepen.ioallows you to host some js files without registration. Once you have an anonymous codepen saved the js part of it is available by just adding a .js
at the end of your url.
codepen.io允许你在没有注册的情况下托管一些 js 文件。一旦你有一个匿名代码笔保存了它的 js 部分,只需.js
在你的 url 末尾添加一个即可。
回答by harry kumar
jsdelivris a free, fast and reliable service to host your javascript files on a CDN.
The file should be on github repository first, then use the following format to use the CDN:-
jsdelivr是一种免费、快速且可靠的服务,用于在 CDN 上托管您的 javascript 文件。
该文件应该首先在github存储库上,然后使用以下格式使用CDN:-
https://cdn.jsdelivr.net/gh/user/repo@version/file
In the above format replace user with your username on github, repo with repository name and version with the version of your repository
You can use this CDN service for hosted anywhere like npmjs.com or even on your wordpress sites using their plugin.
Please visit the website for more information and to know how it works.
在上述格式中,将 user 替换为您在github上的用户名,将 repo 替换为存储库名称,将版本替换为您的存储库版本
您可以使用此 CDN 服务托管在 npmjs.com 等任何地方,甚至使用他们的插件在您的 wordpress 站点上进行托管。
请访问该网站以获取更多信息并了解其工作原理。