{"data":{"id":96,"slug":"detecting-lazy-loaded-content-part-5-96","title":"Detecting lazy-loaded content, part 5","excerpt":"In part 5 we take the ideas from earlier instalments and apply them to a larger, messier site. Lazy loading defers images and sections until they are about to scroll into view. A script that reads…","seriesName":"Detecting lazy-loaded content","seriesPart":5,"sections":[{"heading":"Introduction","paragraphs":["In part 5 we take the ideas from earlier instalments and apply them to a larger, messier site. Lazy loading defers images and sections until they are about to scroll into view. A script that reads the page immediately sees placeholders instead of content."]},{"heading":"Going further","paragraphs":["Deduplicate as you go. The same item often appears on several listing pages, and a stable identifier such as a SKU or ID makes duplicates easy to spot.","Pagination comes in several shapes: numbered pages, next links, offsets and opaque cursors. Each has trade-offs, and a robust scraper should detect the end of the result set rather than assuming a fixed number of pages.","Selectors are the most fragile part of any scraper. Prefer stable attributes such as data-testid or semantic structure over generated class names, which can change on every deploy."]},{"heading":"Common pitfalls","paragraphs":["Keep configuration such as base URLs, delays and selectors out of your code. Changing a delay should not require a redeploy.","Log every request with its URL, status code and duration. When something goes wrong at two in the morning, those logs are the difference between a quick fix and a long investigation."]},{"heading":"Key takeaway","paragraphs":["Scroll the element into view and wait for its real attributes to appear, or read the data-src style attributes that hold the eventual values."]}],"authorId":9,"authorName":"Mateo Hughes","authorSlug":"mateo-hughes","category":"Browser Automation","tags":["javascript"],"publishedAt":"2026-09-05T00:00:00.000Z","wordCount":213,"readingTimeMinutes":2}}