Using Mod_pagespeed causes javascript failures

302 views
Skip to first unread message

Martin Corby

unread,
Mar 10, 2015, 4:02:25 AM3/10/15
to mod-pagesp...@googlegroups.com
A page that runs fine with mod_pagespeed commented out, has multiple js issues when mod_pageseped is allowed to run.

Development page with pagespeed OFF- http://logcabinkits.co.uk/test4.php?ModPagespeed=off

Development page with pagespeed ON - http://logcabinkits.co.uk/test4.php

With no page speed, the following file loads fine : <script src="http://logcabinkits.co.uk/JS/all.js.min.js" type="text/javascript"></script>

But with pagespeed on, the source code reveals : <script type="text/javascript">//<![CDATA[ //]]></script>

Jeff Kaufman

unread,
Mar 10, 2015, 7:37:37 AM3/10/15
to mod-pagespeed-discuss
What I'm seeing:

Without pagespeed:

"""
<script src="http://logcabinkits.co.uk/JS/all.js.min.js"
type="text/javascript"></script>

<script>
function lCss(url, media) {
var d = document;
var l = d.createElement('link');
l.rel = 'stylesheet';
l.type = 'text/css';
l.href = url;
l.media = media;
d.getElementsByTagName('head')[0].appendChild(l);
}
function deferredCSS() {
lCss('http://logcabinkits.co.uk/css/delayed.css', 'all');
lCss('http://logcabinkits.co.uk/css/layout.css', 'all');
lCss('http://fonts.googleapis.com/css?family=Roboto:400,300,700')
}
if (window.addEventListener) {
window.addEventListener('DOMContentLoaded', deferredCSS, false);
} else {
window.onload = deferredCSS;
}
</script>


<script type="text/javascript">
<!--
// Create a function that will receive data sent from the server
function getInstallation(str)
{
var xmlhttp;
if (str=="")
{
document.getElementById("costing").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("costing").innerHTML=xmlhttp.responseText;
}
}
var cabinSize=$("#cabinSize").val();
xmlhttp.open("GET","../ajax/installation.php?pcode="+str+"&cabinSize="+cabinSize,true);
xmlhttp.send();
}
//-->
</script>

<script async type="text/javascript"
src="//s7.addthis.com/js/300/addthis_widget.js#pubid=martincorby"></script>

<script type="text/javascript"
src="http://logcabinkits.co.uk/JS/detailsScripts.js"></script>

<!-- START : Image Zoom Scripts-->
<script type="text/javascript"
src="http://logcabinkits.co.uk/_images/imageZoom/js/jquery.imagezoom.min.js"></script>
<script type="text/javascript"
src="http://logcabinkits.co.uk/_images/imageZoom/js/modernizr.custom.17475.js"></script>
<script type="text/javascript"
src="http://logcabinkits.co.uk/_images/imageZoom/js/jquery.elastislide.js"></script>
<!-- END : Image Zoom Scripts-->
"""

With pagespeed:

"""
<script type="text/javascript">//<![CDATA[

//]]></script>


<script>function lCss(url,media){var d=document;var
l=d.createElement('link');l.rel='stylesheet';l.type='text/css';l.href=url;l.media=media;d.getElementsByTagName('head')[0].appendChild(l);}
function deferredCSS(){lCss('http://logcabinkits.co.uk/css/delayed.css','all');lCss('http://logcabinkits.co.uk/css/layout.css','all');lCss('http://fonts.googleapis.com/css?family=Roboto:400,300,700')}
if(window.addEventListener){window.addEventListener('DOMContentLoaded',deferredCSS,false);}else{window.onload=deferredCSS;}</script>


<script type="text/javascript">function getInstallation(str)
{var xmlhttp;if(str=="")
{document.getElementById("costing").innerHTML="";return;}
if(window.XMLHttpRequest)
{xmlhttp=new XMLHttpRequest();}
else
{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}
xmlhttp.onreadystatechange=function()
{if(xmlhttp.readyState==4&&xmlhttp.status==200)
{document.getElementById("costing").innerHTML=xmlhttp.responseText;}}
var cabinSize=$("#cabinSize").val();xmlhttp.open("GET","../ajax/installation.php?pcode="+str+"&cabinSize="+cabinSize,true);xmlhttp.send();}</script>

<script async type="text/javascript"
src="//s7.addthis.com/js/300/addthis_widget.js#pubid=martincorby"></script>

<script src="http://logcabinkits.co.uk/JS,_detailsScripts.js+_images,_imageZoom,_js,_jquery.imagezoom.min.js+_images,_imageZoom,_js,_modernizr.custom.17475.js+_images,_imageZoom,_js,_jquery.elastislide.js.pagespeed.jc.z0dJCHW3_R.js"></script><script>eval(mod_pagespeed_pk7LeGYgeO);</script>

<!-- START : Image Zoom Scripts-->
<script>eval(mod_pagespeed_bj5Nn6CtIL);</script>
<script>eval(mod_pagespeed_FwGLoHngzL);</script>
<script>eval(mod_pagespeed_ENaLU3J7Yl);</script>
<!-- END : Image Zoom Scripts-->
"""

The changes I'm seeing:
1) http://logcabinkits.co.uk/JS/all.js.min.js was inlined as an empty
file. Very bad.
2) The next two script blocks, with ICSS and getInstallation, were
properly minified. Good.
3) addthis_widget.js was unmodified, because it's on someone else's
server. Expected.
4) the last four external scripts were properly combined. Good.

So, as you said, the problem is that all.js.min.js is getting inlined
as an empty file.

Is it possible that at some point in the past
http://logcabinkits.co.uk/JS/all.js.min.js might have returned an
empty file with a long cache lifetime? If you clear your cache, does
that fix the problem?
> --
> You received this message because you are subscribed to the Google Groups
> "mod-pagespeed-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mod-pagespeed-di...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mod-pagespeed-discuss/6c12a9df-72ec-4897-bed1-9d4d101e14bb%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Martin Corby

unread,
Mar 10, 2015, 8:29:56 AM3/10/15
to mod-pagesp...@googlegroups.com
Jeff

Thanks for your prompt reply.

As far as the cache is concerned, are you referring to a browser or server cache ?

Jeff Kaufman

unread,
Mar 10, 2015, 9:24:54 AM3/10/15
to mod-pagespeed-discuss
mod_pagespeed's server-side cache:
https://developers.google.com/speed/pagespeed/module/system#flush_cache
> --
> You received this message because you are subscribed to the Google Groups
> "mod-pagespeed-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mod-pagespeed-di...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mod-pagespeed-discuss/5b050522-c610-4311-bc9e-3d608954af9e%40googlegroups.com.

Martin Corby

unread,
Mar 10, 2015, 2:14:16 PM3/10/15
to mod-pagesp...@googlegroups.com
Jeff

Thanks for the link through to the information on flushing the system cache - I am assuming the commands mentioned are all done via the shell, in which case it goes beyond my current skill set.

So, with the knowledge that there was an issue with a cached version of all.js.min.js I changed its name to all.js.min.a.js and for a couple of page refreshes it helped, but now the problem has returned.

Within view source, on line 39, pagespeed also appears to have added an additional script tag ?

Now I am confused ?!

On Tuesday, 10 March 2015 08:02:25 UTC, Martin Corby wrote:

Shawn Ligocki

unread,
Mar 10, 2015, 4:31:44 PM3/10/15
to mod-pagesp...@googlegroups.com
Thanks Martin, we have a suspicion for what could be causing this bug. Could you try the following:

1) Add
to your pagespeed.conf file.
2) Restart Apache
3) Clear the cache (changing the filename again is a great way to do this).

and see if this is still broken?

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-di...@googlegroups.com.

Martin Corby

unread,
Mar 10, 2015, 5:27:51 PM3/10/15
to mod-pagesp...@googlegroups.com
Shaun

Requested inputs now actioned - sorry, but problem persists.


On Tuesday, 10 March 2015 08:02:25 UTC, Martin Corby wrote:

Shawn Ligocki

unread,
Mar 10, 2015, 5:48:05 PM3/10/15
to mod-pagesp...@googlegroups.com
Martin, are you saying that you disabled InPlaceResourceOptimization, restarted and cache flushed. But the bug still occurs?

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-di...@googlegroups.com.

Martin Corby

unread,
Mar 10, 2015, 6:07:33 PM3/10/15
to mod-pagesp...@googlegroups.com
Yes, that is correct


On Tuesday, 10 March 2015 08:02:25 UTC, Martin Corby wrote:

Martin Corby

unread,
Mar 11, 2015, 3:47:24 AM3/11/15
to mod-pagesp...@googlegroups.com
Yes, this is correct. The problem persists


On Tuesday, 10 March 2015 08:02:25 UTC, Martin Corby wrote:

Shawn Ligocki

unread,
Mar 11, 2015, 1:55:13 PM3/11/15
to mod-pagesp...@googlegroups.com
Martin, can you send me a copy of your pagespeed.conf?

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-di...@googlegroups.com.

Shawn Ligocki

unread,
Mar 11, 2015, 1:59:25 PM3/11/15
to mod-pagesp...@googlegroups.com
Martin, when I visit http://logcabinkits.co.uk/test4.php now it seems to be consistently including all.js.min.a.js. Are you still seeing the problem on this page? Using which browser.

On Wed, Mar 11, 2015 at 1:55 PM Shawn Ligocki <slig...@google.com> wrote:
Martin, can you send me a copy of your pagespeed.conf?

On Wed, Mar 11, 2015 at 3:47 AM Martin Corby <martinc...@gmail.com> wrote:
Yes, this is correct. The problem persists


On Tuesday, 10 March 2015 08:02:25 UTC, Martin Corby wrote:
A page that runs fine with mod_pagespeed commented out, has multiple js issues when mod_pageseped is allowed to run.

Development page with pagespeed OFF- http://logcabinkits.co.uk/test4.php?ModPagespeed=off

Development page with pagespeed ON - http://logcabinkits.co.uk/test4.php

With no page speed, the following file loads fine : <script src="http://logcabinkits.co.uk/JS/all.js.min.js" type="text/javascript"></script>

But with pagespeed on, the source code reveals : <script type="text/javascript">//<![CDATA[ //]]></script>

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-discuss+unsub...@googlegroups.com.

Martin Corby

unread,
Mar 11, 2015, 2:04:32 PM3/11/15
to mod-pagesp...@googlegroups.com
Shaun

I have requested a copy of the pagespeed.conf file and will get this to you just as soon as it arrives with me.

The next part is interesting as I have actually changed the name of this js file to all.js.min.b.js , but omitted to change the reference in the script test4.php

I have now updated test4.php to the correct js file address




On 11/03/2015 17:59, 'Shawn Ligocki' via mod-pagespeed-discuss wrote:
Martin, when I visit http://logcabinkits.co.uk/test4.php now it seems to be consistently including all.js.min.a.js. Are you still seeing the problem on this page? Using which browser.

On Wed, Mar 11, 2015 at 1:55 PM Shawn Ligocki <slig...@google.com> wrote:
Martin, can you send me a copy of your pagespeed.conf?

On Wed, Mar 11, 2015 at 3:47 AM Martin Corby <martinc...@gmail.com> wrote:
Yes, this is correct. The problem persists


On Tuesday, 10 March 2015 08:02:25 UTC, Martin Corby wrote:
A page that runs fine with mod_pagespeed commented out, has multiple js issues when mod_pageseped is allowed to run.

Development page with pagespeed OFF- http://logcabinkits.co.uk/test4.php?ModPagespeed=off

Development page with pagespeed ON - http://logcabinkits.co.uk/test4.php

With no page speed, the following file loads fine : <script src="http://logcabinkits.co.uk/JS/all.js.min.js" type="text/javascript"></script>

But with pagespeed on, the source code reveals : <script type="text/javascript">//<![CDATA[ //]]></script>

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-di...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mod-pagespeed-discuss/eXkKcwnJG_o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mod-pagespeed-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/CACNG_45bFL-k%2B6HLkz%3D1-JKoWsLn1Jv%2BLtsd0w2%3Dc03NMXQ0Eg%40mail.gmail.com.

Martin Corby

unread,
Mar 11, 2015, 2:09:47 PM3/11/15
to mod-pagesp...@googlegroups.com
In the source code, what is referenced on line 38 "<script pagespeed_no_defer="">//<![CDATA[" ?




On 11/03/2015 17:59, 'Shawn Ligocki' via mod-pagespeed-discuss wrote:
Martin, when I visit http://logcabinkits.co.uk/test4.php now it seems to be consistently including all.js.min.a.js. Are you still seeing the problem on this page? Using which browser.

On Wed, Mar 11, 2015 at 1:55 PM Shawn Ligocki <slig...@google.com> wrote:
Martin, can you send me a copy of your pagespeed.conf?

On Wed, Mar 11, 2015 at 3:47 AM Martin Corby <martinc...@gmail.com> wrote:
Yes, this is correct. The problem persists


On Tuesday, 10 March 2015 08:02:25 UTC, Martin Corby wrote:
A page that runs fine with mod_pagespeed commented out, has multiple js issues when mod_pageseped is allowed to run.

Development page with pagespeed OFF- http://logcabinkits.co.uk/test4.php?ModPagespeed=off

Development page with pagespeed ON - http://logcabinkits.co.uk/test4.php

With no page speed, the following file loads fine : <script src="http://logcabinkits.co.uk/JS/all.js.min.js" type="text/javascript"></script>

But with pagespeed on, the source code reveals : <script type="text/javascript">//<![CDATA[ //]]></script>

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-di...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mod-pagespeed-discuss/eXkKcwnJG_o/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mod-pagespeed-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mod-pagespeed-discuss/CACNG_45bFL-k%2B6HLkz%3D1-JKoWsLn1Jv%2BLtsd0w2%3Dc03NMXQ0Eg%40mail.gmail.com.

Shawn Ligocki

unread,
Mar 11, 2015, 2:34:50 PM3/11/15
to mod-pagesp...@googlegroups.com
Martin, I now see 


on line 599 when I look at the source on Chrome: view-source:http://logcabinkits.co.uk/test4.php . This is the correct behavior, right?

The script on line 38 looks unrelated to me.

Martin Corby

unread,
Mar 11, 2015, 3:07:27 PM3/11/15
to mod-pagesp...@googlegroups.com
Yes, this element does appear to be functioning correctly thanks - why is pagespeed generating the spurious code on line 38 ?

Shawn Ligocki

unread,
Mar 11, 2015, 3:16:54 PM3/11/15
to mod-pagesp...@googlegroups.com
PageSpeed inserts JS for various reasons, this code is used by the Critical Images filter to identify which images are visible to most users when they first visit the page.

Glad to hear that this is working again. It looks like InPlaceResourceOptimization was to blame.

We have not been able to reproduce this bug, so it would help if you could turn ModPagespeedInPlaceResourceOptimization on again. Can you do that without harming your user-visible pages? Thanks.

Martin Corby

unread,
Mar 13, 2015, 4:24:41 AM3/13/15
to mod-pagesp...@googlegroups.com
Shawn

Copy of pagespeed.conf now attached for info. 

I will also adjust ModPagespeedInPlaceResourceOptimization as requested

Thank you for you time and help, really appreciated

Rgds
Martin


On Tuesday, 10 March 2015 08:02:25 UTC, Martin Corby wrote:
pagespeed.conf.bak

Shawn Ligocki

unread,
Mar 13, 2015, 9:18:49 AM3/13/15
to mod-pagesp...@googlegroups.com

I don't see any of the changes you made here. For example, disabling filters or turning off ModPagespeedInPlaceResourceOptimization. Could you send the file you made those changes to?


--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-di...@googlegroups.com.

Shawn Ligocki

unread,
Mar 13, 2015, 9:24:12 AM3/13/15
to mod-pagesp...@googlegroups.com
Oops, my mistake, I see ModPagespeedInPlaceResourceOptimization is turned off in here and that you have not disabled other filters. Sorry for the confusion. Thanks for helping us to debug this :)

On Fri, Mar 13, 2015 at 9:18 AM Shawn Ligocki <slig...@google.com> wrote:

I don't see any of the changes you made here. For example, disabling filters or turning off ModPagespeedInPlaceResourceOptimization. Could you send the file you made those changes to?


On Fri, Mar 13, 2015, 4:24 AM Martin Corby <martinc...@gmail.com> wrote:
Shawn

Copy of pagespeed.conf now attached for info. 

I will also adjust ModPagespeedInPlaceResourceOptimization as requested

Thank you for you time and help, really appreciated

Rgds
Martin


On Tuesday, 10 March 2015 08:02:25 UTC, Martin Corby wrote:
A page that runs fine with mod_pagespeed commented out, has multiple js issues when mod_pageseped is allowed to run.

Development page with pagespeed OFF- http://logcabinkits.co.uk/test4.php?ModPagespeed=off

Development page with pagespeed ON - http://logcabinkits.co.uk/test4.php

With no page speed, the following file loads fine : <script src="http://logcabinkits.co.uk/JS/all.js.min.js" type="text/javascript"></script>

But with pagespeed on, the source code reveals : <script type="text/javascript">//<![CDATA[ //]]></script>

--
You received this message because you are subscribed to the Google Groups "mod-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mod-pagespeed-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages