Lazy Loading and XPath

Lazy loading analysis with xpath by Screaming Frog

Lazy Loading Analysis

This insight starts with a tweet from Jonattan Moore who shares with the Seo community how to crawl images in Lazy Loading using XPath from Screaming Frog.

Lazy Loading of Images

Let us begin by understanding what Lazy Loading is in order to fully appreciate Jonathan’s work.

You know when you’re browsing a web page and as you scroll down new images keep popping up?

This feature is called “Lazy Loading” and corresponds to an “on-demand” loading that is executed only when requested by the user’s navigation and is used for all those elements that would affect the performance of the page if run in the first instance with the rest of the elements in the main thread (it would also affect the Core Web Vitals).

Since loading speed is one of the pillars in Search Engine Ranking attribution this strategy that provides a better user browsing experience is to be taken into absolute consideration.

Lazy Loading and Google

So, based on the premise, this strategy is advisable for all websites to improve the user experience for surfers, but what does Leader Maximo Google think about this implementation?

Google indulges this choice but warns to be very careful in the implementation so as not to prevent the Bot from crawling the resources uploaded via “Lazy Loading” otherwise it may not index them.

In summary, the Search Engine approves of this technique but asks to make sure that he can see all the resources to be evaluated in indexing. To better understand what Google is asking for, I encourage you to read its dedicated guide: Make sure Google can see lazy-loaded content.

The aspects that every developer must consider are essentially 3:

  • Load content when it is visible in the viewport: to allow the Google Bot a complete crawl of the page make sure that lazy loading loads all content whenever it is visible in the “viewport” using the IntersectionObserver API and a polyfill.
  • In case of “Infinite Scroll” put a “Paginated” upload in support.
  • Test the proper functioning of Lazy Loading: you can use a script such as Puppeteer, a Node.js library directly locally to verify that the screenshots that have been generated by the script show all the content on the page.


Lazy Loading Audit

Once we understand the general outlines related to Lazy Loading of images we take advantage of Screaming Frog ‘s Custom Extraction feature to do an audit of a page’s overall images and those loaded only via on-demand loading.

Learn more about Seo Spider’s Custom Extraction feature here.

Below are the XPath paths shared by Jonathan Moore for Custom Extraction.

For ease of use I report them in text form:

Copy to Clipboard

Using these parameters you can obtain the following results directly in Screaming Frog’s “Custom Extraction” tab divided by columns and available for your optimization analysis.

Related Tab: Custom Extraction | Sidebar

Seo Spider Tab