jquery ui - 如何使用谷歌CDN [英] jquery ui - how to use google CDN

查看:277
本文介绍了jquery ui - 如何使用谷歌CDN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将谷歌CDN用于jQuery和jQuery UI ..

I want to use Google CDN for jQuery and jQuery UI..

我正在使用jQuery的答案。
使用谷歌托管的jQuery的最佳方式,但回到我在谷歌上的托管库失败

I'm using the answer from here for jQuery. Best way to use Google's hosted jQuery, but fall back to my hosted library on Google fail

但我不明白这一点:

if (typeof jQuery == 'undefined')

那么我怎样才能为jQuery UI做到这一点?
也可以使用自定义jQuery UI主题,因为这也会生成一个自定义的js文件吗?

so how can i do it for jQuery UI? also, will this work with custom jQuery UI theme as this produces a custom js file too?

推荐答案

你可以使用

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" media="all" /> 
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js" type="text/javascript"></script>

您还可以通过更改主题名称链接到其他Ui主题。在这种情况下,将名称库更改为任何其他主题名称 /base/jquery-ui.css 到任何其他主题。

You can also link to other Ui themes by changes the name of the theme. In This case change the name base to any other theme name /base/jquery-ui.css to any other theme.

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" media="all" />

查看jQuery UI博客,获取所有CDN链接的链接 http://blog.jqueryui.com/

Check out the jQuery UI Blog for a link of all CDN links http://blog.jqueryui.com/

如果您担心谷歌CDN曾经失败或失败,你可以在CDN离线时回到本地副本(这个例子被放到像HTML5 Boilerplate这样的模板中):

If you're concerned that the Google CDN ever fails or goes down, you can fall back to a local copy when the CDN is offline (this example is baked into templates like HTML5 Boilerplate):

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
    window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"></script>')
</script>

这篇关于jquery ui - 如何使用谷歌CDN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆