Page 1 of 1

[DONE] RFE: work around ?ModPagespeed=noscript

Posted: Sat Dec 28, 2013 1:33 pm
by thunderscript
Hello Giorgio. After the holidays, would you please work around ModPagespeed (an Apache module by Google) which hides already downloaded pages? Maybe as a script surrogate? Websites are increasingly using this for optimization.

In short, if scripts are disabled, ModPagespeed creates a <noscript> element with both a redirect and a stylesheet to hide already downloaded page.
Redirection can be blocked with noscript.forbidMetaRefresh set to true.
Website is downloaded, but hidden from view within the <noscript> tag's <style>.

I believe a surrogate could only strip <style> from inside <noscript> if ModPagespeed is detected, so if a user is already blocking meta-redirects inside <noscript>, they get a working website.

Code: Select all

<noscript><meta HTTP-EQUIV="refresh" content="0;url='http://www.example.com/?ModPagespeed=noscript'" /><style><!--table,div,span,font,p{display:none} --></style><div style="display:block">Please click <a href="http://www.example.com/?ModPagespeed=noscript">here</a> if you are not redirected within a few seconds.</div></noscript>
An example URL and where it redirects to:

Code: Select all

http://www.mhpbooks.com/
http://www.mhpbooks.com/?ModPagespeed=noscript
I wish you pleasant time and happy holidays. :)

Re: RFE: work around ?ModPagespeed=noscript

Posted: Sat Dec 28, 2013 6:42 pm
by barbaz
for now, try this surrogate?

Code: Select all

noscript.surrogate.modpagespeed.replacement : window.addEventListener("load", function(){for(let o of document.querySelectorAll("noscript style"))o.parentNode.removeChild(o);}, false)
noscript.surrogate.modpagespeed.sources : !^https?://
you might want to modify the "sources" pref so that this doesn't apply to all pages

Re: RFE: work around ?ModPagespeed=noscript

Posted: Sun Jan 05, 2014 4:09 pm
by barbaz
and if modpagespeed *always* inserts a meta element that tries to redirect you to a url containing "ModPagespeed" (case-sensitive), you can try this surrogate

Code: Select all

noscript.surrogate.modpagespeed.replacement : window.addEventListener("load", function(){if(document.querySelector('meta[content*="ModPagespeed"]') != null){for(let o of document.querySelectorAll("noscript style"))o.parentNode.removeChild(o);}}, false)
noscript.surrogate.modpagespeed.sources : !^https?://

Re: RFE: work around ?ModPagespeed=noscript

Posted: Mon Jan 06, 2014 11:19 am
by thunderscript
Hello barbaz. Thank you, that works like a charm. Yes, Google programmed it to always contain ModPagespeed in the redirected URL.

Have a nice day and a happy New Year! :)

@Giorgio, would you please consider adding this to your list of surrogates?

Re: RFE: work around ?ModPagespeed=noscript

Posted: Tue Jan 14, 2014 3:06 pm
by Giorgio Maone
thunderscript wrote:@Giorgio, would you please consider adding this to your list of surrogates?
Slightly modified version in latest development build 2.6.8.12rc4. Thank you both!

Re: RFE: work around ?ModPagespeed=noscript

Posted: Fri Jan 17, 2014 12:56 am
by thunderscript
Sweet, works great. Thank you.