简体   繁体   English

mod_pagespeed删除外部(第三方CDN)js资源

[英]mod_pagespeed removes external (third party cdn) js resources

I'm wondering why? 我想知道为什么吗? is it a requirement of pagespeed to store all javascript locally? Pagespeed是否需要在本地存储所有JavaScript?

I found this in my pagespeed.conf 我在pagespeed.conf中找到了这个

# ModPagespeedDomain
# authorizes rewriting of JS, CSS, and Image files found in this
# domain. By default only resources with the same origin as the
# HTML file are rewritten.

However, this doesn't seem to be the case when external js files are just chucked off the DOM. 但是,当外部js文件刚刚从DOM中删除时,情况似乎并非如此。

EDIT 编辑

Ok, so with the default settings third party js resources located in the head section. 好的,使用默认设置,第三方js资源位于头部。 ex: 例如:

  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js"></script>
  <script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>

is removed from the source code with pagespeed. 使用pagespeed从源代码中删除。 So i did a bit of digging and fooled around with different settings. 因此,我做了一些挖掘工作,并用不同的设置来弄弄。 And what i came up with is that it seems that the following filtes causes the issue: 我想出的是,似乎以下filtes导致了该问题:

combine_css
inline_css

What i did was that i enabled one filter at a time until i got the "error". 我所做的是我一次启用了一个过滤器,直到出现“错误”为止。

This has to be a bug? 这一定是个错误吗? doesn't it? 是不是

There are 4 problems here that are contriving to break this example: 这里有四个问题试图打破这个例子:

  1. You claim the doc is XHTML via DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ... 您通过DOCTYPE html PUBLIC“-// W3C // DTD XHTML 1.0 ...
  2. You don't close the link-tags on lines 9-12 (see attachment of Issue 292 -- link below) 您不会关闭第9-12行的链接标记(请参见第292期的附件-以下链接)
  3. mod_pagespeed 0.9.16.9 believed the XHTML tag implies balanced tags mod_pagespeed 0.9.16.9认为XHTML标签意味着平衡标签
  4. mod_pagespeed should be more pessimistic in the presence of unbalanced tags. 在存在不平衡标签的情况下,mod_pagespeed应该更加悲观。

Fixing any one of these 4 problems will resolve this. 解决这4个问题中的任何一个将解决此问题。 Problems 3 & 4 are fixed in 0.9.17.3, which is available in source-code form but not yet as a binary. 问题3和4在0.9.17.3中已修复,可以源代码形式提供,但不能以二进制形式使用。 We're in the process of releasing this. 我们正在发布此文件。

This issue is also reported as http://code.google.com/p/modpagespeed/issues/detail?id=292 which is really a duplicate of http://code.google.com/p/modpagespeed/issues/detail?id=252 此问题也报告为http://code.google.com/p/modpagespeed/issues/detail?id=292 ,它实际上是http://code.google.com/p/modpagespeed/issues/detail的副本?ID = 252

No, mod_pagespeed doesn't require that you only use local JavaScript resources. 不, mod_pagespeed不需要只使用本地JavaScript资源。

If your CDN links use the nifty "leave off the protocol" trick , it may be worth looking to see if that's confusing mod_pagespeed . 如果您的CDN链接使用了漂亮的“摆脱协议”技巧 ,那么可能值得一看,看看这是否使mod_pagespeed感到困惑。

If not, take a look at your pagespeed.conf (or wherever you're keeping your pagespeed config options). 如果不是,请查看您的pagespeed.conf (或保留pagespeed配置选项的任何位置)。 It sounds like something is mis-configured. 听起来好像配置错误。 Configuration options are listed here . 配置选项在此处列出 There are a couple related to JavaScript, including combine_javascript and inline_javascript . 有一些与JavaScript相关的东西,包括combine_javascriptinline_javascript I wouldn't expect either of those to relate to files being loaded from CDNs, but it may be worth taking a look. 我不希望它们中的任何一个都与从CDN加载的文件有关,但是可能值得一看。 (Sadly the documentation page for the combine_javascript option is messed up right now, it's an exact copy of the page for the combine_css option . I've reported that as a bug .) (可悲的是,目前combine_javascript选项的文档页面已被弄乱,它是combine_css选项的页面的精确副本。我已经将其报告为bug 。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM