Google CDN Jquery 加载不工作
目前,我的一个布局中有一组丑陋的单独的 javascript 文件,我正在尝试使用 Google CDN 清理它。
当前状态(我知道很糟糕):
...css...
<%= yield :head %>
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" %>
<script type="text/javascript" src="http://cdn.jquerytools.org/1.2.5/all/jquery.tools.min.js"></script>
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js" %>
<%= javascript_include_tag "ui/jquery.ui.core", "ui/jquery.effects.core",
"ui/jquery.effects.highlight", "ui/jquery.ui.widget", "ui/jquery.ui.tabs",
"ui/jquery.ui.progressbar" %>
<%= javascript_include_tag "jquery.ui.stars.min", "application", "rails" %>
我尝试将底部标签中的第二个(带有一长串文件)替换为:
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js" %>
我没有运气 - 似乎谷歌文件根本不存在(我检查了我的页面源并已加载)。我在这里做错了什么?
I currently have an ugly array of separate javascript files in one of my layouts and I'm trying to clean it up using the Google CDN.
Current state (horrible I know):
...css...
<%= yield :head %>
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" %>
<script type="text/javascript" src="http://cdn.jquerytools.org/1.2.5/all/jquery.tools.min.js"></script>
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js" %>
<%= javascript_include_tag "ui/jquery.ui.core", "ui/jquery.effects.core",
"ui/jquery.effects.highlight", "ui/jquery.ui.widget", "ui/jquery.ui.tabs",
"ui/jquery.ui.progressbar" %>
<%= javascript_include_tag "jquery.ui.stars.min", "application", "rails" %>
I tried replacing the 2nd from bottom tag (with the long list of files) with:
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js" %>
I am getting no luck with that - it seems as if the google file is not there at all (I checked my page source and it is loaded). What am I doing wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道如何将其转换为 RAILS,但这个简单的 HTML 应该可以解决问题。
这假设您的 jQuery 文件存储在
/includes/jquery-1.4.2.min.js
上。当 Google 的 CDN 出现故障时,将获取本地副本。
I don't know how to translate it into RAILS but this simple HTML should do the trick.
This would assume that your jQuery file is stored on
/includes/jquery-1.4.2.min.js
.On Google's CDN failure, local copy will get fetched.
很抱歉翻出旧帖子,但我不确定问题是否得到了真正的回答。
我遇到了和你类似的问题,解决方案实际上很简单:我没有包含 CSS。您也可以通过 Google 的 CDN 来做到这一点:
或者
显然这是针对 ui-lightness 主题的; CDN 上还有其他可用主题(尽管不是全部)。我相信您可以通过 Google 快速搜索找到这些内容。
Sorry to dredge up an old post, but I'm not sure the question was actually answered.
I had a similar problem as you did, and the solution was actually quite simple: I was not including the CSS. You can do so through Google's CDN as well:
or
Obviously this is for the ui-lightness theme; there are other themes available on the CDN (though not all of them). I'm sure you can find those with a quick Google search.