Does Google Index Content Generated By JavaScript?

JavaScriptGoogle’s web crawler is sophisticated enough to index content dynamically generated by JavaScript.

In the days of yore, everything that appeared on a web page was stored on a server or generated by a process running on a server. Web browsers received and rendered HTML pages that were more-or-less complete in themselves. From a search engine crawler’s perspective, that was all good, because it could just take the HTML and index the content.

The modern web is a different place. Content — including HTML — is often generated by code executed in the browser. In the simplest case, a script might grab data from an external API and insert it into the document. In more complex web applications, the entire page might be generated by JavaScript. Most modern sites fall somewhere in-between. A content management system like WordPress generates much of a page’s content on the server, but pages often contain JavaScript that has to be executed for the page to render as intended.

It’s helpful here to understand the difference between the code sent by a server and the DOM — the Document Object Model. The DOM is used by browsers to render the page that appears to the user. When all the content of a page is sent from the server, there’s an obvious mapping between the code and the DOM. If a web crawler like Googlebot can understand the HTML and CSS the server sends, it knows all it needs to know about the page.

But when content is dynamically generated by JavaScript, the story is different. Interactive web applications and similar sites work by updating the DOM. The browser is sent HTML, CSS, and JavaScript files. It builds the DOM based on those files and executes the JavaScript, which may well change the DOM.

Consider a single-page website: one in which page transitions are handled in JavaScript. Every time the user clicks on an internal link, the JavaScript changes the HTML used to build the DOM and hence render the page, or it may interact directly with the DOM (or a virtual DOM).

The question is this: how well does Google’s crawler handle content dynamically generated by JavaScript? Or, put another way, how much understanding does Google’s crawler have of a DOM that’s actively modified by code. This matters because if the crawler isn’t capable of executing JavaScript, indexing dynamically generated content, and following dynamically generated links, the SEO situation of such sites is not good.

In fact, it seems that Google handles dynamically generated content quite well: its crawlers can execute Javascript and index dynamically generated content. Marketer Adam Audette ran a comprehensive series of tests on Google’s understanding of the DOM, and in the most important factors that influence SEO, Googlebot passed with flying colors.

Take a look at the full test results to get an idea of how Google handles dynamic content and other common JavaScript patterns, but the takeaway is that Google’s crawler is quite capable of handling JavaScript-generated content and links.

Matthew Davis is a technical writer and Linux geek for Future Hosting.

Dedicated Server Special

Take advantage of our Double RAM offer on the E3-1230v2 4 x 3.30GHz+HT server! Only $134.95 per month. Managed and Unmanaged options available at checkout.