IP Board "quote" broken by "pagespeed_no_defer" script

329 views
Skip to first unread message

Miguel Clara

unread,
Feb 13, 2014, 10:49:51 AM2/13/14
to ngx-pagesp...@googlegroups.com

After enabling pagespeed I noticed a weired isssue with a IP Board Installation.

When using the quote button, apart from the quote I alsso get this text:

<script pagespeed_no_defer="">(function(){var e=encodeURIComponent,f=window,h=document,m="width",n="documentElement",p="height",q="length",r="prototype",s="body",t="&",u="&ci=",w="&n=",x="&rd=",y=",",z="?",A="Content-Type",B="Microsoft.XMLHTTP",C="Msxml2.XMLHTTP",D="POST",E="application/x-www-form-urlencoded",F="img",G="input",H="load",I="oh=",J="on",K="pagespeed_url_hash",L="url=",M=function(a,c,d){if(a.addEventListener)a.addEventListener(c,d,!1);else if(a.attachEvent)a.attachEvent(J+c,d);else{var b=a[J+c];a[J+c]=function(){d.call(this);b&&b.call(this)}}};f.pagespeed=f.pagespeed||{};var N=f.pagespeed,O=function(a,c,d,b,g){this.d=a;this.f=c;this.g=d;this.a=g;this.c={height:f.innerHeight||h[n].clientHeight||h[s].clientHeight,width:f.innerWidth||h[n].clientWidth||h[s].clientWidth};this.e=b;this.b={}};O[r].j=function(a){a=a.getBoundingClientRect();return{top:a.top+(void 0!==f.pageYOffset?f.pageYOffset:(h[n]||h[s].parentNode||h[s]).scrollTop),left:a.left+(void 0!==f.pageXOffset?f.pageXOffset:(h[n]||h[s].parentNode||h[s]).scrollLeft)}};O[r].i=function(a){if(0>=a.offsetWidth&&0>=a.offsetHeight)return!1;a=this.j(a);var c=a.top.toString()+y+a.left.toString();if(this.b.hasOwnProperty(c))return!1;this.b[c]=!0;return a.top<=this.c[p]&&a.left<=this.c[m]};O[r].l=function(){for(var a=[F,G],c=[],d={},b=0;b{d=y+e(c[b]);if(131072=a[q]+d[q]&&(a+=d),b=!0);N.criticalImagesBeaconData=a;if({var c=this.d,b=this.f,l;if(f.XMLHttpRequest)l=new XMLHttpRequest;else if(f.ActiveXObject)try{l=new ActiveXObject(C)}catch(P){try{l=new ActiveXObject(}catch(Q){}}l&&(l.open(D,c+(-1==c.indexOf(z)?z:t)+L+e(),l.setRequestHeader(A,E),l.send(a))}};O[r].h=function(){for(var a={},c=h.getElementsByTagName(F),d=0;d=a[b.src].n&&b[p]>=a[b.src].m)a[g]={renderedWidth:b[m],renderedHeight:b[p],originalWidth:b.naturalWidth,originalHeight:b.naturalHeight}}return a};N.k=function(a,c,d,b,g){var k=new O(a,c,d,b,g);M(f,H,function(){f.setTimeout(function(){k.l()},0)})};N.criticalImagesBeaconInit=N.k;})();pagespeed.criticalImagesBeaconInit('/ngx_pagespeed_beacon','https://forums.plex.tv/index.php?s=7c52f3b4f6a969052159ac848c76a011&app=forums&module=ajax§ion=topics&do=quote&t=59548&p=353044&md5check=ca71f5bc3a13296b51446351e109b37e&isRte=1','W2PyaY9kww',false,'8ByaY1t0dHM');</script>


The thing is I don't have defer_javascript enabled, and even tried to disable it with no look, here's my current config:

        # PageSpeed
        pagespeed on;
        pagespeed FileCachePath /var/cache/ngx_pagespeed_cache;

        # Filters Enabled
        pagespeed RewriteLevel CoreFilters;
        pagespeed EnableFilters collapse_whitespace,remove_comments;
        pagespeed DisableFilters defer_javascript;


        #  Ensure requests for pagespeed optimized resources go to the pagespeed
        #  handler and no extraneous headers get set.
        location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; }
        location ~ "^/ngx_pagespeed_static/" { }
        location ~ "^/ngx_pagespeed_beacon$" { }
        location /ngx_pagespeed_statistics {
                allow 127.0.0.1;
                deny all;
        }
        location /ngx_pagespeed_global_statistics {
                allow 127.0.0.1;
                deny all;
        }
        location /ngx_pagespeed_message {
                allow 127.0.0.1;
                deny all;
        }
        location /pagespeed_console {
                allow 127.0.0.1;
                deny all;
        }


Also, I tried to complete remove page_speed form the IPB config, and rebuild IPB cache, and this issue persists? How can that be? :|

Any help is appreciated thanks

Joshua Marantz

unread,
Feb 13, 2014, 11:06:26 AM2/13/14
to ngx-pagesp...@googlegroups.com
That script is not actually the result of defer_javascript.  It is the result of code injected by PageSpeed for clients to send back hints to the server indicating which images are above-the-fold.  In that script we specify pagespeed_no_defer so it does not get deferred, in case you have defer_javascript off.  We could probably change the injection logic to avoid bothering with pagespeed_no_defer when defer_javascript is disabled.

To disable the injection of that script, you can specify:

   pagespeed CriticalImagesBeaconEnabled off;

However, then the inline_images filter and others will be less effective.  I did not understand what this means: 
"When using the quote button, apart from the quote I alsso get this text:".  Do you mean that JS fragment was actually injected into the browser display?

RE your last question, turning pagespeed off but still seeing that issue -- I'm guessing it's some kind of other caching in your setup.

-Josh


--
You received this message because you are subscribed to the Google Groups "ngx-pagespeed-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ngx-pagespeed-di...@googlegroups.com.
Visit this group at http://groups.google.com/group/ngx-pagespeed-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Miguel Clara

unread,
Feb 13, 2014, 11:14:06 AM2/13/14
to ngx-pagesp...@googlegroups.com

[ the remove part was my bad... forgot I add it enabled in the main config ]

Miguel Clara

unread,
Feb 13, 2014, 4:17:01 PM2/13/14
to ngx-pagesp...@googlegroups.com


On Thursday, February 13, 2014 4:06:26 PM UTC, Joshua Marantz wrote:
That script is not actually the result of defer_javascript.  It is the result of code injected by PageSpeed for clients to send back hints to the server indicating which images are above-the-fold.  In that script we specify pagespeed_no_defer so it does not get deferred, in case you have defer_javascript off.  We could probably change the injection logic to avoid bothering with pagespeed_no_defer when defer_javascript is disabled.

To disable the injection of that script, you can specify:

   pagespeed CriticalImagesBeaconEnabled off;

However, then the inline_images filter and others will be less effective.  I did not understand what this means: 
"When using the quote button, apart from the quote I alsso get this text:".  Do you mean that JS fragment was actually injected into the browser display?


Yes that is what I mean the code is injected to the post after the quote block!

I'll check what else CriticalImagesBeaconEnabled might affect and see if its still worth it!



Jan-Willem Maessen

unread,
Feb 13, 2014, 4:27:07 PM2/13/14
to ngx-pagesp...@googlegroups.com
Out of curiosity, what tags (if any) occur after the script on your page?  It looks like we're injecting the script in the wrong place and that's what's causing the trouble, and I'd like to diagnose why this might be.


Miguel Clara

unread,
Feb 13, 2014, 5:31:10 PM2/13/14
to ngx-pagesp...@googlegroups.com


On Thursday, February 13, 2014 9:27:07 PM UTC, Jan-Willem Maessen wrote:
Out of curiosity, what tags (if any) occur after the script on your page?  It looks like we're injecting the script in the wrong place and that's what's causing the trouble, and I'd like to diagnose why this might be.


That's what I see in the inspector... do you want me to expand the div or is that enough?

    <!DOCTYPE html>
    <html lang="en">
        <head></head>
        <body id="ipboard_body" onpageshow="event.persisted && (function(){var allInstances = CKEDITOR.i… doc.$.designMode = "off"; doc.$.designMode = "on"; }}})();">
            <p id="content_jump" class="hide"></p>
            <div id="ipbwrapper"></div>
            <script type="text/javascript"></script>
            <script pagespeed_no_defer=""></script>
            <div id="overlay" style="display: none;"></div>
            <div id="lightbox" style="display: none;"></div>
            <input id="hte_editor_52fd475215632" type="text" style="position: absolute; left: -1000px; display: none;" undefined="position:absolute;left:-1000px;display:none;"></input>
            <div id="ajax_loading" style="display: none;"></div>
        </body>
    </html>

On Thu, Feb 13, 2014 at 4:17 PM, Miguel Clara <miguel...@gmail.com> wrote:


On Thursday, February 13, 2014 4:06:26 PM UTC, Joshua Marantz wrote:
That script is not actually the result of defer_javascript.  It is the result of code injected by PageSpeed for clients to send back hints to the server indicating which images are above-the-fold.  In that script we specify pagespeed_no_defer so it does not get deferred, in case you have defer_javascript off.  We could probably change the injection logic to avoid bothering with pagespeed_no_defer when defer_javascript is disabled.

To disable the injection of that script, you can specify:

   pagespeed CriticalImagesBeaconEnabled off;

However, then the inline_images filter and others will be less effective.  I did not understand what this means: 
"When using the quote button, apart from the quote I alsso get this text:".  Do you mean that JS fragment was actually injected into the browser display?


Yes that is what I mean the code is injected to the post after the quote block!

I'll check what else CriticalImagesBeaconEnabled might affect and see if its still worth it!



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

Miguel Clara

unread,
Feb 17, 2014, 1:10:05 PM2/17/14
to ngx-pagesp...@googlegroups.com
Did the last post help? Or do you need more details?

The workarroud does break other filters and the site get way slower, so it better to just disable pagespeed for now

Jan-Willem Maessen

unread,
Feb 18, 2014, 11:34:22 AM2/18/14
to ngx-pagesp...@googlegroups.com
That was definitely helpful, thanks.  It'll take a bit of work before this gets solved I think.  I've opened a bug (against mod_pagespeed as this is a problem in the shared code base):

Please weigh in with anything you think I may have missed!

On Mon, Feb 17, 2014 at 1:10 PM, Miguel Clara <miguel...@gmail.com> wrote:
Did the last post help? Or do you need more details?

The workarroud does break other filters and the site get way slower, so it better to just disable pagespeed for now

I'm curious what broke.  You won't see image inlining happening above the fold, and image lazyload will be disabled, but everything else (ordinary image, CSS, JS optimizations etc.) should work OK.

-Jan
 

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

Miguel Clara

unread,
Feb 18, 2014, 12:00:17 PM2/18/14
to ngx-pagesp...@googlegroups.com


On Tuesday, February 18, 2014 4:34:22 PM UTC, Jan-Willem Maessen wrote:
That was definitely helpful, thanks.  It'll take a bit of work before this gets solved I think.  I've opened a bug (against mod_pagespeed as this is a problem in the shared code base):

Please weigh in with anything you think I may have missed!

On Mon, Feb 17, 2014 at 1:10 PM, Miguel Clara <miguel...@gmail.com> wrote:
Did the last post help? Or do you need more details?

The workarroud does break other filters and the site get way slower, so it better to just disable pagespeed for now

I'm curious what broke.  You won't see image inlining happening above the fold, and image lazyload will be disabled, but everything else (ordinary image, CSS, JS optimizations etc.) should work OK.

-Jan

I would need to investigate better, to be honest the thing I diffidently notice was slowness.... I my slower than without pagespeed! I've setup a test install using the same IPB DB just to test nginx with pagespeed on, and I should be able to see more I guess, but I'm very new to pagespeed, this is my first attempt on using it in production so I'm not exactly sure what to look for!

Miguel Clara

unread,
Apr 16, 2014, 11:36:27 PM4/16/14
to ngx-pagesp...@googlegroups.com
Wonder if this issues was fixed? 

I've updated to 1.7.30.4 and tested but IP board still get this issue!

Works fine with Wordpress!

Thanks
Reply all
Reply to author
Forward
0 new messages