-
-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make sure Google can see lazy-loaded content #277
Comments
Hi @DimLeon, That's a good point, and a good question, thank you for asking it. I didn't get what is the "normal img demo" that is correctly working, but I'll do some tests myself using puppeteer too. I'll keep you updated. |
Hey @DimLeon,
...and the results from puppeteer, which FAILED, says: "If there are more images in the screenshot below, the page is using scroll events to lazy load images. Instead, consider using another approach like IntersectionObserver." My objections:
I copied the way of detecting a bot from LazySizes, which is the first script that the Google Developers page advices. :) So help me out here, I don't understand what to do next to fix this issue. |
Thanks for the reply @verlok. Also thank you for this plugin.
The result in the "passed" demos is:
Doesn' t really make sense to me. I don't know how to help, since there is no scroll events in your code and Intersection Observer is used instead. I' will try to use the Googlebot Images crawler as indicated here: https://support.google.com/webmasters/answer/6066468?hl=en |
I'm experiencing the same issues. I have ordinary i've tried:
It never passes🤷♂️ On the first image (Page without being scrolled) there are no images, on the last (Page after scrolling) – some of them. EDIT: In my case this is caused by first screen being Test says "FAILED", but it's due to me using some parallax, so when two screenshots compared, images are misaligned after scroll. |
Setting small dimensions (400 x 300) in that puppeteer script, I have yet to find a lazyload example (this or other libraries/script) that passes. testing: which makes me wonder if the script is a good example; I think using a placeholder - actually having a src - is key to making everyone happy. |
Would you try with version 11.0.0? |
I just tried this version and I fetched as Google my site. Only the first image shows, the rest don't load.. but additionally Google ends up failing to even run masonry, so it's as if it runs into some error. I'm not sure what could be the issue. Does the LazyLoad() have to be run after document.ready() ? Or can it be called anywhere? I called it in right after loading the script.. I tried with data-src only, and no srcset, and still same problem. On my end it loads fine however, but it seems Google runs into some issue. |
Yes, DOM needs to be ready. From the recently updated README (that I invite you to read and give feedback, especially the “Getting started” section):
Hope this helps! |
Moreover, is there any chance that JS might be disabled in the Chrome run by Puppeteer? |
It runs @verlok as far i can see -- with the exception of when a screenshot is taken.
the print preview is missing all the images which haven't been scrolled to; they don't show as they don't have a |
Thank you @dan-ding for your explanation, but that’s not the case because the LazyLoad script reads the user agent string and, if found to be a Bot like Google Bot or Bing Bot or others, triggers the |
Ya -- just trying to help(?) some understand what the puppet is doing. I'm not a fan of the ua sniffing, however i'm not raising an issue with it. |
Me neither, but I didn’t find another way to do that. If anyone have any suggestions, you’re welcome. |
This is the code LazyLoad uses to detect whether or not the browser is a bot. export const runningOnBrowser = typeof window !== "undefined";
export const isBot =
(runningOnBrowser && !("onscroll" in window)) ||
(typeof navigator !== "undefined" &&
/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent)); First of all, it checks if we're running on a browser, then if the browser has the In my previous comment, I tested that code in the browser console and as you can see, if Also other lazyload libraries use this same technique, so I guess this is working, but:
Can you help me out with this? |
@verlok i wanted to avoid the question of the UA as I understand why you put it in. It wasn't meant to be a complaint. Also -- the example puppeteer script does not set the UA to googlebot without modification. I'll write up some better tests (since that example doesn't use the lazyload we care about ;) and get back to you |
Thank you 🙏🏼 |
Google scrolls down just like any other browser. I am using another Jquery script that does not do any UA testing and Fetch as google was loading every image fully. I should've tested this plugin better, but now the good fetch as Google tool that fetched the first 10,000pixels has been taken offline, and it's impossible to test lazy image loading any more, because the new tool only shows the first image. Very sad Google has chosen to do this. |
Thank you for your contribution @otterslide. I really don’t know how to test this as Google. Just to make it clearer, LazyLoad first checks if the |
Using the old Fetch as Google tool, this script was only loading the first
image for me, which was very odd. The new fetch as google tool does not
scroll down at all so I cannot test any lazy loading scripts any longer.
I'd encourage everyone to click the feedback button in the webmaster fetch
as google tool and complain that the screenshot is too small.
Having said that, it is said that Googlebot uses Chrome 41. I tested your
demo page with Chrome 41 and it pre-loads all images right off the start,
so probably Chrome 41 doesn't have scroll events.
Unfortunately, I am finding that scroll event scripts are being deferred by
ad loading. The scripts initialize, but Google DFP ads somehow block the
entire script from loading anything until the ads are completely loaded.
Maybe they block the scroll event, not sure.. With IntersectionObserver I
am finding that this doesn't happen, and loading is quite a bit faster. I
also can use polyfill and even on Chrome 41 the images can be lazy loaded.
As you probably know, intersection observer runs in a separate thread as
well, which should be better for performance. I didn't want to open another
issue for this, let me know if I should, I'd be interested in your input on
the possibility of other scripts interfering with the lazy load script. I
only noticed recently because some ads were taking very long to load. It
would take a good 5-10seconds to start loading any image.
Thanks.
|
I believe I solved this issue tonight, it finally dawned upon me...
|
@knoxcard thanks for trying comment. It just seems to add two event listeners to each image,
What does this kind of code solve? |
Some conclusions i came up to: I used the google's search console and made some url inspection for my website. (the old 'fetch as google'). Unfortunately, my lazy images are not shown in the screenshot preview. In relevance to the above, some 'seo-related best practices' advise developers using image lazy-loading techniques to add a Any thoughts on this or if this is indeed a good practice would be more than helpful. |
@verlok - html standards require |
Some ideas to check if user is a bot and load all images: Very powerfull but heavy: A faster version: |
@verlok As stated in the PR for the puppeteer script (puppeteer/examples#30) that is referenced on the google docs, adding the UA to the script makes it work. Even though, the results should always be interpreted by a human, since I used that for testing the site I'm working on right now, and the test "failed", but the images were almost exactly the same, with the exception that the images at the far bottom had a different opacity, which, in my case, means that they were the last ones to be scrolled and that their 1sec opacity animation was just finishing. Of course the script would not know that, but since those were the only pixels which had a variation, I can take that result as a good one nonetheless. I'll ask our client if we can upload those images to better exemplify it, since it might be somewhat confusing haha. |
Also, since adding the UA to that script made it work, I guess that the onscroll event and window object exists on that puppeteer script, which might not be exactly the same as when the googlebot crawls the site. Also, the script supposedly should tell whether or not a lazyload approach uses scroll events or Intersection Observer API, but I'm guessing it's not working as expected, since this solution uses the IO API. For the time being, I wouldn't worry too much about this. |
Thank you all! |
I tried to run a test for my website as suggested in this link: https://developers.google.com/search/docs/guides/lazy-loading
by using a puppeteer script but the test results are: "Lazy images loaded correctly: Failed".
I then ran the test for the 2 demos provided in the docs, concerning the responsive images lazyload (srcset & with picture tag) https://www.andreaverlicchi.eu/lazyload/demos/with_srcset_lazy_sizes.html and the result was once again "Lazy images loaded correctly: Failed".
However, running the same test for the normal img demo (no srcset, no picture) the result was "passed".
Any idea what is wrong?
The text was updated successfully, but these errors were encountered: