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

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

问题描述

我想将 Google CDN 用于 jQuery 和 jQuery UI..

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

我将这里的答案用于 jQuery.使用 Google 托管的 jQuery 的最佳方法,但退回到我在 Google 上的托管库失败

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 更改为任何其他主题名称 /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/

如果您担心 Google 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天全站免登陆