Does GoogleBot run JavaScript?

I’ve been looking at a friend’s turtle site recently and thinking about search engine optimization. It’s always been said that Google needs to see what’s on your site to index it, but now that JavaScript (and especially AJAX) are becoming more prevalent, I wonder.. does Google run the JavaScript code on my site?

I could see a bot setting up a specialized JavaScript execution environment and running the code on the site, and then indexing the final product, rather than indexing just what you get when you read the bytes that come from the HTTP GET request… but this could also be problematic. It would seriously slow the bot down, for example, since it would be doing things like pulling the Google AdSense-based ads (having to wait for all that code to run) before indexing. It would also make the bot vulernable to denial-of-service attacks by sites that sense the bot and deliver code with CPU-wasting loops (for example).

But on the other hand, looking at Ray’s site, you can see that a bot that indexed the results of loading the page AFTER the JavaScript had run would see more of the page than before (for example, the ‘news ticker’ text – it’s currently in a div tag but other versions have it being fetched by JavaScript that animates it, which would probably hit it from the bots).

Does any bot do this now?