jquery - 如何正确使用谷歌加载器

标签 jquery google-code

我已经使用以下内容一段时间了:

    <script src="https://www.google.com/jsapi?key=MY_API_KEY" type="text/javascript"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>

但是,我见过其他谷歌加载器替代品,例如只需加载 jQuery 本身(注意:http):

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>

这种替代方法意味着您不需要调用第一个示例。

使用 Google 加载程序时最好使用哪种方法?

最佳答案

您可以使用其中任何一个。 正如Google Libraries API中提到的介绍中

The Libraries API provides your applications with stable, reliable, high-speed, globally available access to all of the most popular, open-source JavaScript libraries. Your application can use our very flexible loader google.load() or direct, path-based access to the scripts.

我更喜欢直接加载库(你的第二个选择),因为我认为不需要加载 google 库以及 jquery

如果您的页面本身是httpS,请使用httpS。否则,就使用http

关于jquery - 如何正确使用谷歌加载器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7902358/

相关文章:

java - 在哪里寻找开源 Java 库?

javascript - 使用模态弹出联系表单,是否可以在提交时在同一弹出窗口中显示确认?

javascript - IE8中动态创建选择框选项问题

jquery - 使用jquery附加vue js组件

wiki - 如何将某个页面设置为 Google 代码上的默认 wiki 页面?

git - 跨 Github、Sourceforge 和 Google Code 镜像存储库

google-code - 谷歌代码本身的错误——向哪里报告?

javascript - 我可以将 Angular 2 引入现有的 JS/jQuery/PHP 项目吗?

javascript - 我想使用 GIN 将 JSON 数据带到 Golang 制作的服务器