从 Google 的 CDN 下载 jQuery UI CSS

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/820412/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 09:52:23  来源:igfitidea点击:

Downloading jQuery UI CSS from Google's CDN

jquerycssjquery-uicdngoogle-ajax-libraries

提问by coool

I am planning on using Google to download the jQuery lib for both UI and Core. My question is, do they allow me to download the CSS for it or should I have to host it myself?

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

Also if I use Google to load how should I load other plugins? Can I compress all plugins together or should it be its own separate file?

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

回答by cletus

The Google AJAX Libraries API, which includes jQuery UI (currently v1.10.3), also includes popular themes as per the jQuery UI blog:

Google AJAX 库 API 包括 jQuery UI(当前为 v1.10.3),还包括jQuery UI 博客中的流行主题:

Google Ajax Libraries API (CDN)

Google Ajax 库 API (CDN)

回答by Dustin Woodard

jQuery now has a CDN access:

jQuery 现在有一个 CDN 访问:

code.jquery.com/ui/[version]/themes/[theme name]/jquery-ui.css

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



And to make this a little more easy, Here you go:

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

回答by Dustin Woodard

Google is hosting jQueryUI css at this link https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery.ui.all.css

谷歌在这个链接上托管 jQueryUI css https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery.ui.all.css

If you look at this code directly, it is importing the css using @import which can be slow. You may want to factor the import into its parts to gain a slight performance benefit:

如果您直接查看此代码,它会使用 @import 导入 css ,这可能会很慢。您可能希望将导入考虑到其部分以获得轻微的性能优势:

https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery.ui.base.csshttps://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery.ui.theme.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

回答by Scott Evernden

I would think so. Why not? Wouldn't be much of a CDN w/o offering the CSS to support the script files

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

This linksuggests that they are:

此链接表明它们是:

We find it particularly exciting that the jQuery UI CSS themes are now hosted on Google's Ajax Libraries CDN.

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

回答by samueldple

You could use this one if you mean the jQuery UI css:

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

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

回答by aWebDeveloper

As Obama says "Yes We Can". Here is the link to it. developers.google.com/#jquery

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

You need to use

你需要使用

Google

谷歌

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

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

Microsoft

微软

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

Find theme names here http://jqueryui.com/themeroller/in gallery subtab

在这里找到主题名称http://jqueryui.com/themeroller/在画廊子选项卡中

.

.

But i would not recommendyou hosting from cdn for the following reasons

但由于以下原因,我不建议您从 CDN 托管

  1. Although your chance of hit rate is good in case of Google CDN compared to others but it's still abysmally low.(any cdn not just google).
  2. Loading via cdn you will have 3 requests one for jQuery.js, one for jQueryUI.js and one for your code. You might as will compress it on your local and load it as one single resource.
  1. 尽管与其他 CDN 相比,在 Google CDN 的情况下,您的命中率很高,但它仍然非常低。(任何 CDN 不只是 google)。
  2. 通过 cdn 加载您将有 3 个请求,一个用于 jQuery.js,一个用于 jQueryUI.js,一个用于您的代码。您可以将其压缩到本地并将其作为单一资源加载。

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

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