incubator-pagespeed-ngx
incubator-pagespeed-ngx copied to clipboard
anchored links break when javascript is disabled in browser (for users of noscript)
When javascript is disabled (this is common for users of Tor Browser) anchored links are broken
For example, https://www.whonix.org/wiki/Hardened-kernel#Upstreaming is rewritten to https://www.whonix.org/wiki/Hardened-kernel?PageSpeed=noscript
If anything it should be: https://www.whonix.org/wiki/Hardened-kernel?PageSpeed=noscript#Upstreaming
Why is this happening?
Can this be prevented?
Hi Your site works w/o javascript? If your site don´t work well w/o javascript then you can disable the noscript filter (by default is enabled)
pagespeed SupportNoScriptEnabled false;
This disable adding the /?PageSpeed=noscript
Lofesa:
Your site works w/o javascript?
Yes. My site works sufficiently well without javascript. At least anonymous reading and anchor links are well functional.
Found https://www.modpagespeed.com/doc/faq#noscript-redirect just now (had wrong search terms in mind earlier).
The defer_javascript, lazyload_images, dedup_inlined_images, and local_storage_cache filters require JavaScript to render pages correctly. To support clients that have JavaScript disabled, if any of these filters are enabled, PageSpeed will insert a meta refresh inside a noscript tag at the top of the page. This meta refresh will redirect clients with JavaScript disabled to the current URL with a '?PageSpeed=noscript' query parameter appended which disables filters that require JavaScript.
That actually sounds really good. But why does it break anchored link for example #Upstreaming?
Hi
Test:
In Chrome 80.0.3987.149, I have disabled javascript, then
I go to https://www.whonix.org/wiki/Hardened-kernel,
this page redirect me to https://www.whonix.org/wiki/Hardened-kernel?PageSpeed=noscript,
then I look for the "Upstreaming" link
clik and go to the anchor
In the url bar I can see https://www.whonix.org/wiki/Hardened-kernel?PageSpeed=noscript#Upstreaming
So is working. The file is not a zip file, you must download it and change the file extension deleting the .zip
That is correct.
However, when sharing a link such as https://www.whonix.org/wiki/Hardened-kernel#Upstreaming it redirects to https://www.whonix.org/wiki/Hardened-kernel?PageSpeed=noscript and the user is presented the top of the page.
(As if visiting https://www.whonix.org/wiki/Hardened-kernel.)
The same in other words:
- disable javascript
- open a blank browser tab (I used Tor Browser with security slider setting maximum and Chromium with noscript)
- paste
https://www.whonix.org/wiki/Hardened-kernel#Upstreaminginto the URL bar
Expected result:
See chapter Upstreaming.
Actual result: See top of that page.
Ah! I see... But I think is the spected behaviour. The filter only add a meta refresh label w/ only 1 uri. The meta refreh work in this way: 1st. check if the browser have javascript enabled and if not, then do a page refresh with redirect to the specified uri, in this case w/ ?PageSpeed=noscript to disbale some filters. All the anchor magic is done client side, the server can´t recevie the anchor part. See this https://stackoverflow.com/questions/1637211/get-anchor-from-uri
I've added pagespeed SupportNoScriptEnabled false; to config and this made my page work better with javascript disabled. Anchored links now functional. That was, pagespeed SupportNoScriptEnabled false; is counter-intuitive. (I didn't like users seeing any different link ?PageSpeed=noscript being appended anyhow. Users tend to share links with query parameters intact which makes links ugly.)
Nothing else can be done about this? Possible feature request / bug report? I.e. have the cake and eat it too?
Hi
I think is not in hand of this module change the http spec.
The purpose of ?PageSpeed=noscript is for disable some filter that need javascript to work.
The metatag refresh (http spec) do a internal redirect to one and only one uri, in this case to the main url with the parameter to disable pagespeed filters.
In the server side, the anchors are unknow (http spec), so can´t manipulate it. To manipulate the anchors you need some thing in the client side (javascript) but is disabled.
Not using the ?PageSpeed=noscript make some filters don´t work and maybe throw some error mesages in dev tools console. If your site works well s/o making these redirect to disable filters, I can see any mayor problem...