Google search console for some reason picks up the partial file reference from our LazyLoad JS and throws a 404 error saying the following file is missing:
http://example.com/wp-content/plugins/wp-rocket/inc/front/js/lazyload-
This is a false positive and can be ignored. But we get tickets regarding this and it bothers some of our users.
Possible solution - Include a dummy file with the file name. Worked for a user.
Related tickets:
Explore how this can be resolved using robots_txt
filter instead of a dummy file - https://developer.wordpress.org/reference/hooks/robots_txt/
https://docs.wp-rocket.me/article/1085-lazyload-404-error-in-google-search-console
Blocking the broken URL via robots.txt doesn’t seem to be reliable. One customer reported the URL got “indexed though blocked by robots.txt”.
Thanks @glueckpress . Having a dummy file isn't an elegant solution either.
Maybe instead of
var v = !("IntersectionObserver" in w) ? "8.7.1" : "10.5.2";
s.src = "https://www.example.com/wp-content/plugins/wp-rocket/inc/front/js/lazyload-" + v + ".min.js";
we should simply go for:
s.src = !("IntersectionObserver" in w) ? "https://www.example.com/wp-content/plugins/wp-rocket/inc/front/js/lazyload-8.7.1.min.js" : "https://www.example.com/wp-content/plugins/wp-rocket/inc/front/js/lazyload-10.5.2.min.js";
@Tabrisrp - Is this a better solution?
I like this better yes