Search code examples
javascriptjqueryajaxseogooglebot

Does google bot trigger javascript click actions on site and solution to it?


So what is our problem at the moment we are having reviews from products on our site and to optimize the page load on desktop and mobile we are loading only 10 reviews initialy and then on each button click per user interaction we load next 10 reviews. So we want from Google and other search engines to index the content from other reviews that are not initialy showed. We have stacked our code in vanilla javascript with

jQuery( function() {
    ...
    document.getElementById("ID").onclick( function(...) );
    ...
});

but after reading some articles, I found out that Google crawler can eventually access only content that is loaded on document ready. So I am asking if anyone had similar problem to this one and how did they solve it or if there are any other workarounds for this problem?

I have read that Google crawler can execute javascript now and that Google deprecated their solution that they were recommending before https://developers.google.com/webmasters/ajax-crawling/docs/learn-more.

Here I found another advice from Google: https://support.google.com/webmasters/answer/81766?hl=en under section Develop with progressive enhancement

PS: HTML element with "ID" is button, does google suggestion indicates we should replace it with anchor?

Thank you in advance.


Solution

  • A common way is to use a pagination, where each page has a few items and a unique URL, then Google can index these pages.

    Progressive enhancement means that you can then use Javascript to replace the pagination menu with a button that loads the next items by ajax as you do now.