How we built an infinite scroll for PrestaShop that doesn't hide products from Google
Many shops want customers to browse the catalogue without clicking page numbers, but those who try usually get two surprises: products vanishing from Google and customers who, coming back from a product page, have to start from the top. We wanted an infinite scroll that brings the comfort without either cost.
Why it isn't trivial
- Search engines don't scroll. They follow links. If later pages only exist through JavaScript, products beyond page one drop out of the index.
- Every theme paginates its own way. Classic uses links, Hummingbird in PrestaShop 9 uses buttons, the 1.6 theme and many commercial templates have their own markup.
- Filters rewrite the listing. Faceted search replaces the products without reloading the page, and on 1.6 it turns links into hash addresses.
- Going back has to work. The browser doesn't remember what JavaScript loaded, so without extra work customers land on page one again.
The approach: improve pagination, don't replace it
The design rule was that the server keeps printing every page in full, with the theme's pagination. The script only hides it once it has started correctly, and the Load more button is itself a link to the next page. Without JavaScript, with a wrong selector or on any failure, the shop navigates as usual.
- Three modes: button, real infinite scroll or mixed, with a different mode on mobile.
- Address and title follow the visible page, so reloading, sharing and Analytics work.
- Server-side SEO: title and description per page, self canonical, rel prev/next, optional noindex on filters and crawlable links for themes that paginate with buttons.
Technical decisions
Restoring the position without cookies
Loaded products and the position are kept in sessionStorage for a few minutes and restored on return, with the visited product highlighted. Visitors entering on page 4 can load the previous ones above without the content jumping.
Detecting non-standard templates
Besides recognising the usual themes, the module analyses a listing of the shop itself: it looks for the element whose children each hold a different product, the pagination and the next link, and proposes selectors the merchant applies with one click. A debug panel shows in the shop what it found.
Checking what a crawler sees
An SEO check downloads the listing and its page 2 as plain HTML, like a crawler, and checks link, canonical, title and noindex. In Docker and some hosting setups the shop can't download itself through its domain, so it retries through the local address.
Performance
Placeholders that reserve the space of products (better CLS), configurable preload and statistics aggregated per day without personal data, to choose the mode with real figures.
How we tested it
Automated browser tests on PrestaShop 1.6, 1.7, 8 and 9: automatic and button loads, address and title per page, back navigation with restored position, previous pages, faceted search and behaviour without JavaScript, also with hand-set selectors. Along the way we solved cases like fast scrolls skipping the trigger and blocklayered's hash links.
What we learnt
Better experience and good SEO aren't at odds if the improvement is built on top of what already works instead of replacing it. It is the same approach we bring to the integrations, automations and custom developments we build for our clients.
What this development demonstrates
- Load more button, real infinite scroll or mixed, with its own mobile mode
- Real pagination in the HTML and full operation without JavaScript
- URL, canonical and title per page, rel prev/next and crawlable links
- Position restored when coming back from a product and previous pages loading
- Non-standard theme analysis and crawler-style SEO check
- Native faceted search support on PrestaShop 1.6 to 9