incubator-pagespeed-ngx
incubator-pagespeed-ngx copied to clipboard
Duplicated javascript files loading in browser based on Chrome
I found out that if we enable defer_javascript
or lazyload_images
filtres, some of the JS files on the website load twice.
I checked that on Firefox and didn't get the same result, so I assume that this is Chromium-based browsers' behavior.
Also, I found out this bug https://github.com/apache/incubator-pagespeed-mod/issues/1054 which I think is related to this.
It load twice the exact same file? or load 1 time the file and 1 time the rewrited by pagespeed url?
Second option: first the PageSpeed rewritten file then the original file.
Can you verify if you have a link header to preload the asset? Pagespeed don´t rewrite headers, so if you have it then you have 1st the header and 2nd the html, this last is rewrited by pagespeed and are not the same file name, but had the same content.
https://strongboxtechnology.10web.cloud/
here is the website, as you can see it loads wp-content/cache/tw_optimize/js/two_07f45a878040049d26642d9ad2754c36.js.pagespeed.jm.jNGuvHpZaz.js
and wp-content/cache/tw_optimize/js/two_07f45a878040049d26642d9ad2754c36.js
.
If you open https://strongboxtechnology.10web.cloud/?PageSpeed=off you'll see that there is only one load of that file.
I think the issue is not related to pagespeed module but other plugin you have.
Some plugin (maybe other way) put files as a link preload header, that is rewrited (have the pagespeed stuf in it) but in the html the file get untouched by pagespeed because it have <!--This script contains introspective JavaScript and is unsafe to replace.-->
Same thing occurs with your jquery.js, but in this case both files (header link and html code) are the same (with pagespeed stuff in it)
You may avoid this with:
pagespeed AvoidRenamingIntrospectiveJavascript off;
but this can cause problems. Or can avoid this file to be pushed as a link header and then only load the file in the html code.
But there is no preloaded js with disabled PageSpeed module.
There is something wrong with hint_preload_subresource
the issue is gone when I disable that filter
This filter (hint_preload_subresource), when work (I've never gotten it to work), create the preload header, maybe the filter creates it with the rewrited url, but latter the filter rewrite_javascript can´t rewrite the url in the html because is unsafe to change, this make downlod the same file 2 times, one rewrited and other w/o rewrite.
Yep, I also think so