Does Google execute JavaScript?
August 6, 2016
I’m told: Yes, it’s 2016; of course Google executes JavaScript.
But I’m also told: Server-side rendering is necessary for SEO.
If Google can run JavaScript and thereby render client-side views, why is server-side rendering necessary for SEO? Okay, Google isn’t the only search engine, but it’s obviously an important one to optimize for.
Recently I ran a simple experiment to see to what extent the Google crawler understands dynamic content. I set up a web page at doesgoogleexecutejavascript.com which does the following:
- The HTML from the server contains text which says “Google does not execute JavaScript.”
- There is some inline JavaScript on the page that changes the text to “Google executes JavaScript, but only if it is embedded in the document.”
- The HTML also links to a script which, when loaded, changes the text to “Google executes JavaScript, even if the script is fetched from the network. However, Google does not make AJAX requests.”
- That script makes an AJAX request and updates the text with the response from the server. The server returns the message “Google executes JavaScript and even makes AJAX requests.”
After I launched this page, I linked to it from its GitHub repository and waited for Google to discover it. Within a day, I saw the following in Google search:

I waited a week to see if Google would re-crawl the page and run the JavaScript—no dice. Then I manually submitted the page to the index from the Google Search Console. Shortly thereafter, I saw this:

It seems Google is not guaranteed to run your JavaScript automatically. You may have to manually trigger a crawl. And, even then, Google apparently won’t do any AJAX requests your page may depend on, or at least it didn’t in my case.
New Years Update (1/1/2017): Apparently some time after I did this experiment Google re-indexed the page and did the AJAX call this time:

Thanks pul for pointing that out.
My conclusion is: Google may or may not decide to run your JavaScript, and you don’t want your business to depend on its particular inclination of the day. Do server-side/universal/isomorphic rendering just to be safe.