Jquery 如何正确使用GoogleLoader

Jquery 如何正确使用GoogleLoader,jquery,google-code,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> 但是,我

我已经用了一段时间了:

    <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>

但是,我看到了其他google loader替代方案,例如只加载jQuery本身(注意:http):


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

使用Google loader时,哪种方法是最好的?

您可以使用其中一种。 如引言中所述

库API为您的应用程序提供了稳定、可靠的, 可在全球范围内高速访问所有最受欢迎的, 开源JavaScript库。您的应用程序可以使用我们的 灵活的加载程序google.load()或直接、基于路径访问 脚本

我更喜欢直接加载库(您的第二个选项),因为我认为不需要加载google库和jquery


如果页面本身是httpS,请使用httpS。否则,只需使用http就不需要第一行通过google加载jqueryapi了! 我建议您使用这种方法,以便始终加载jQuery的最新稳定版本:

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

您还可以对查询ui执行相同的操作:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/cupertino/jquery-ui.css"/>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/cupertino/jquery-ui.css"/>