ChatGPT解决这个技术问题 Extra ChatGPT

从 Google 的 CDN 下载 jQuery UI CSS

我计划使用 Google 下载 UI 和 Core 的 jQuery 库。我的问题是,他们允许我为它下载 CSS 还是我必须自己托管它?

另外,如果我使用谷歌加载我应该如何加载其他插件?我可以将所有插件压缩在一起还是应该是它自己的单独文件?


9
9 revs, 8 users 31%

包含 jQuery UI(当前为 v1.10.3)的 Google AJAX 库 API 还包含 jQuery UI blog 中的流行主题:

Google Ajax 库 API (CDN)

未压缩:http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.js

压缩:http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js

未压缩的主题:black tie、blitzer、cupertino、dark-hive、dot-luv、茄子、excite-bike、flick、hot-sneaks、humanity、le-frog、mint-choc、overcast、pepper-grinder、redmond、smoothness ,南街,开始,阳光明媚,时髦的钱包,trontastic,ui-darkness,ui-lightness和vader。

压缩主题:黑色领带、blitzer、cupertino、dark-hive、dot-luv、茄子、excite-bike、flick、hot-sneaks、humanity、le-frog、mint-choc、overcast、pepper-grinder、redmond、smoothness ,南街,开始,阳光明媚,时髦的钱包,trontastic,ui-darkness,ui-lightness和vader。


请注意,这些 CSS 脚本当前没有被压缩/最小化,这意味着您可以从您自己的域中提供减小大小的版本(根据 Google 的 Firefox 的 PageSpeed 插件大约 26%),如果您的连接良好,这对您的用户来说可能会更快他们还没有在本地缓存文件。
每次我想找到这个 CDN 时,我都会输入“jquery ui css google cdn”,而这篇文章是列出所有这些内容的最直接方式。我只想谢谢你 +1
@Drew:或者他也可能使用 Reducisaurus。 :)
@Alix,感谢the link。看起来很有用的服务。
您还可以从 URL 中删除次要版本号,以始终自动获取最新的 CSS/JS。只需保留主要版本号即可。示例:ajax.googleapis.com/ajax/libs/jqueryui/1/themes/ui-lightness/…
J
Josh Crozier

jQuery 现在拥有 CDN 访问权限:

code.jquery.com/ui/[版本]/themes/[主题名称]/jquery-ui.css

为了让这更容易一点,给你:

基地:http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css

黑色领带:http://code.jquery.com/ui/1.9.1/themes/black-tie/jquery-ui.css

闪电战:http://code.jquery.com/ui/1.9.1/themes/blitzer/jquery-ui.css

库比蒂诺:http://code.jquery.com/ui/1.9.1/themes/cupertino/jquery-ui.css

黑暗蜂巢:http://code.jquery.com/ui/1.9.1/themes/dark-hive/jquery-ui.css

点-luv:http://code.jquery.com/ui/1.9.1/themes/dot-luv/jquery-ui.css

茄子:http://code.jquery.com/ui/1.9.1/themes/eggplant/jquery-ui.css

激发自行车:http://code.jquery.com/ui/1.9.1/themes/excite-bike/jquery-ui.css

轻弹:http://code.jquery.com/ui/1.9.1/themes/flick/jquery-ui.css

热门偷拍:http://code.jquery.com/ui/1.9.1/themes/hot-sneaks/jquery-ui.css

人性:http://code.jquery.com/ui/1.9.1/themes/humanity/jquery-ui.css

乐蛙:http://code.jquery.com/ui/1.9.1/themes/le-frog/jquery-ui.css

薄荷巧克力:http://code.jquery.com/ui/1.9.1/themes/mint-choc/jquery-ui.css

阴天:http://code.jquery.com/ui/1.9.1/themes/overcast/jquery-ui.css

胡椒研磨机:http://code.jquery.com/ui/1.9.1/themes/pepper-grinder/jquery-ui.css

雷蒙德:http://code.jquery.com/ui/1.9.1/themes/redmond/jquery-ui.css

平滑度:http://code.jquery.com/ui/1.9.1/themes/smoothness/jquery-ui.css

南街:http://code.jquery.com/ui/1.9.1/themes/south-street/jquery-ui.css

开始:http://code.jquery.com/ui/1.9.1/themes/start/jquery-ui.css

晴天:http://code.jquery.com/ui/1.9.1/themes/sunny/jquery-ui.css

时髦的钱包:http://code.jquery.com/ui/1.9.1/themes/swanky-purse/jquery-ui.css

trontastic:http://code.jquery.com/ui/1.9.1/themes/trontastic/jquery-ui.css

ui-darkness:http://code.jquery.com/ui/1.9.1/themes/ui-darkness/jquery-ui.css

用户界面亮度:http://code.jquery.com/ui/1.9.1/themes/ui-lightness/jquery-ui.css

维达:http://code.jquery.com/ui/1.9.1/themes/vader/jquery-ui.css


它现在支持 https(至少从这篇文章开始)
您如何使用与此 CDN 关联的图像,缺少本地,我不想下载它们。有没有办法使用存储在 CDN 中的那个?
@BaptistePernet:CDN 还提供了所有关联的图像,并且由于 url 语句都相对于 css 文件位置,客户端将自动从 CDN 抓取图像
C
Community

Google 在此链接上托管 jQueryUI css https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery.ui.all.css

如果您直接查看此代码,它正在使用 @import which can be slow 导入 css。您可能希望将导入分解为其部分以获得轻微的性能优势:

https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery.ui.base.css https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery.ui.theme.css


a
aWebDeveloper

正如奥巴马所说的“是的,我们可以”。这是它的链接。 developers.google.com/#jquery

你需要使用

谷歌

ajax.googleapis.com/ajax/libs/jqueryui/[VERSION NO]/jquery-ui.min.js
ajax.googleapis.com/ajax/libs/jqueryui/[VERSION NO]/themes/[THEME NAME]/jquery-ui.min.css

jQuery CDN

code.jquery.com/ui/[VERSION NO]/jquery-ui.min.js
code.jquery.com/ui/[VERSION NO]/themes/[THEME NAME]/jquery-ui.min.css

微软

ajax.aspnetcdn.com/ajax/jquery.ui/[VERSION NO]/jquery-ui.min.js
ajax.aspnetcdn.com/ajax/jquery.ui/[VERSION NO]/themes/[THEME NAME]/jquery-ui.min.css

在图库子标签中的 http://jqueryui.com/themeroller/ 处查找主题名称

.

但我不建议您从 CDN 托管,原因如下

尽管与其他人相比,在使用 Google CDN 的情况下,您的命中率很高,但仍然非常低。(任何 CDN 不仅仅是谷歌)。通过 cdn 加载,您将有 3 个请求,一个用于 jQuery.js,一个用于 jQueryUI.js,一个用于您的代码。您可以将其压缩到本地并将其作为一个资源加载。

http://zoompf.com/blog/2010/01/should-you-use-javascript-library-cdns


你链接的文章是2010年的。他提到的大部分数据都是过时的。现在的点击率要好得多,现在使用 Google CDN 的网站比 2010 年要多得多。
以下是更新的统计数据:blog.cloudharmony.com/2015/02/…现在大多数网站似乎都在使用 CDN。更多数据:w3techs.com/technologies/details/cd-jquerycdn/all/all
S
Scott Evernden

我会这么认为。为什么不?没有提供 CSS 来支持脚本文件的 CDN 不会太多

This link 表明它们是:

我们发现 jQuery UI CSS 主题现在托管在 Google 的 Ajax Libraries CDN 上特别令人兴奋。


我尝试使用 google load 语句添加加载它...不会加载 css ....检查它。
这是一个似乎有效的示例网址:ajax.googleapis.com/ajax/libs/jqueryui/1.7/themes/smoothness/…
n
notquiteamonad

如果你的意思是 jQuery UI css,你可以使用这个:

<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />