-->

When does Googlebot execute javascript?

2020-08-13 04:38发布

问题:

I have a few single page web apps on multiple domains that heavily rely on javascript/ajax to fetch and show content. Based on logs and search results I can tell that googlebot runs javascript on some of the domains but not on others. On some it indexes everything thats only available with js on others it doesn't even seem to run js at all.

Can anybody tell me how googlebot decides what js to run and if I can to anything to get it to run js on my other domains?

PS: I know that normally I should use something like serverside rendering for this, but I'm not at all depended on search results and rankings, so its not really worth the effort. I'm just curious how googlebot decides whether it should run js or not and if there's anything easy I can do to change that on my other domains.

回答1:

You can learn more about how Google render ajax based website and a list of best practice directly from Google developer website here:

https://webmasters.googleblog.com/2014/10/updating-our-technical-webmaster.html https://developers.google.com/webmasters/ajax-crawling/

Regarding your specific problem as first thing, I suggest you to analyse each domain using Google Webmaster tool with functionality "Fetch as Google" and go trough every technical aspects mentioned in Google guide.

https://support.google.com/webmasters/answer/158587?hl=en



回答2:

I think Google Updated Research on the Subject http://searchengineland.com/tested-googlebot-crawls-javascript-heres-learned-220157



回答3:

Now the functionality to fetch your page by Google Bot and see the results has moved into Google Search Console.

You can use URL Inspection Tool to analyze your live URL.

I've tested it on AngularJS App and Google Bot was able to crawl page content with data fetched from AJAX request.



回答4:

One very important restriction is that the Googlebot does not allow AJAX requests while the page is loaded.

In my blog post I am explaining how to adapt a Single Page Application so that it becomes crawlable – without the need to render HTML snapshots on the server.