如何使用 Google 托管的 jQuery UI 源代码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1151978/
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 use Google-hosted jQuery UI source?
提问by chris
I need to load the jQuery UI files, and would like to do it from Google. Currently I upload:
我需要加载 jQuery UI 文件,并希望从 Google 执行此操作。目前我上传:
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.draggable.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.droppable.js"></script>
What are the corresponding files I need from Google?
我需要 Google 提供哪些相应的文件?
Can I use http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js?
我可以使用http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js吗?
Also, is there any disadvantage in using this one instead: http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js?
另外,使用这个有什么缺点吗:http: //ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js?
回答by seth
Yep. It's as simple as that.
是的。就这么简单。
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>
You could use Google's loader to load it but you don't really need to.
您可以使用 Google 的加载程序来加载它,但实际上并不需要。
The only real disadvantage to using the min one is that the code is compressed so if you wanted to step through it with a debugger, it would be quite difficult to say the least. The advantages far outweigh this though. In production, I would say by all means use the min one.
使用 min 的唯一真正缺点是代码被压缩,因此如果您想使用调试器逐步完成它,至少可以说是相当困难的。不过好处远不止这些。在生产中,我会说一定要使用 min 。
回答by Coder
The previous answer gives you a link to a specific version of jqueryui but your question implies that you'd like the Google-based links to the latest versions. These are the correct src's:
上一个答案为您提供了特定版本的 jqueryui 的链接,但您的问题暗示您希望基于 Google 的最新版本链接。这些是正确的 src:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
I see that we're up to version 1.9x at the time of writing. I don't know if the "1" in Google's links will change to a "2" if/when we reach jquery v2. The above links will give you the latest files, anyway, in version 1.
在撰写本文时,我看到我们的版本已达到 1.9x。我不知道如果/当我们到达 jquery v2 时,Google 链接中的“1”是否会更改为“2”。无论如何,以上链接将为您提供版本 1 中的最新文件。
This method doesn't seem to be documented on Google's hosted libraries page, so use with caution. Also the various extra libraries such as draggable / droppable that you've referred to don't seem to be hosted on Google.
Google 的托管库页面上似乎没有记录此方法,因此请谨慎使用。此外,您提到的各种额外库(例如draggable / droppable)似乎并未托管在Google 上。
See: https://developers.google.com/speed/libraries/devguide?hl=fr#jquery
请参阅:https: //developers.google.com/speed/libraries/devguide?hl=fr#jquery
回答by Carolinetis
you have to paste 2 elements:
你必须粘贴 2 个元素:
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
as the developers.google.comsite says
正如developers.google.com网站所说