Isn't Google Processing Javascript Now?

Maybe you've read a blog post announcing to the world: Google Now Reads Javascript! I've read plenty of posts like that myself. And it's true, Google does read some javascript. But how much?

Looking For URLs vs Indexing the Modified DOM
For a long time, Google has scanned javascript for urls. When it does this it isn't executing the javascript at all. It is just looking for patterns in the text that look like urls. Google is doing this to find additional pages that it needs to crawl. Sometimes sites link to pages using onclick events or click handlers. Google wants to follow those links. Just because your logs show Google-bot visited a url that is only listed in your javascript, that doesn't necessarily mean Google is executing the javascript (or at least not all of it).

It's great that Google is finding these extra urls, but a bigger concern to us is DOM manipulation. If you use javascript to add content to your page, is Google going to see that content? Yes. Under some very specific conditions.

What Google Will (Probably) Execute

  • document.write() calls inside <script&gt; tags in the html
  • innterHTML() calls inside <script&gt; tags in the html
    You can do some basic string concatenation and if statements. Keep it very simple. As it get more complicated, you increase the chances that Google will just give up on your code.

What Google (Probably) Won't Execute

  • Any javascript loaded from external files
  • Any AJAX calls
  • Anything too "complicated"

But Someone Told Me They Execute More Than That

Google themselves have stated that they are starting to process some AJAX calls. They are adding more javascript support all the time. However, they still seemed to be focused on the simple, straight forward requests.

I still talk to people everyday who are not having their javascript content indexed. There's no question about that. They have content that is added to the page via javascript, and It is not showing up in Google. Then we use BromBone to create a static html version of the page and the content does show up in Google.

Remember that just because Google executes a certain type of javascript on someone else's website, doesn't mean they have to execute javascript on your site. At the same time, don't be surprised if Google's definition of "simple javascript" keeps expanding.