如何使用谷歌jsapi的jquery和jqueryui

时间:2014-06-14 09:14:57

标签: jquery jsapi

今天我发现其他标准方式"包括jquery和jqueryui:

<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>

还有另一种方法,谷歌jsapi:

<script src="//www.google.com/jsapi"></script>
<script>
google.load("jquery", "1.4.2");
google.load("jqueryui", "1.7.2");
$(function() { $( document ).tooltip(); });
</sciprt>

jsapi方法更好吗?

因为我已经尝试了jsapi方法,但似乎只适用于jquery并且不能使用jqueryui,实际上工具提示没有显示。怎么了?我也应该包括jquery css吗?或者我需要钥匙?

1 个答案:

答案 0 :(得分:3)

这个想法是增强页面的加载。因此,在下载jquery和jqueryui时,您的网页呈现不会被阻止。你也需要加载你的css,我认为你需要内联这样做,所以你仍然需要link标签来加载jqueryui css。

必须承认我并没有真正使用google load api,但它似乎对requirejs做了类似的事情,即动态加载客户端脚本。如果您想以编程方式加载不同的语言,那将非常有用。也许如果你有一个场景,你可能不需要在某些条件下加载jqueryui。

https://developers.google.com/loader/

查看以上内容以获取更多信息。