Sharing Top Content from the Angular-sphere.

Googlebot’s Javascript random() function is deterministic

  • I created a small script which uses this identify Google in an obfuscated fashion: – – The first time Googlebot calls the result will always be , the second call will always be .
  • Optimisations will need to be abundant, and I imagine that having a deterministic random number function is probably: – – Googlebot also seems to run Javascript with a sped up clock, which makes sense.
  • If you create a simple ticker script and put it through the Google Search Console ‘Fetch & Render’ function it returns almost instantly, but with results looking like this: – – The second date is a date from the future!
  • I did wonder if the random number generation sometimes updates, but a Google search for turns up over 18,000 results, so it seems like it is quite stable.
  • After discovering this I Google about a bit and found an old Hacker News comment by ‘KMag’: – – So it seems things were similar to this for some time now, but instead of always returning , it became a deterministic series.

I was conducting some experiments on how Googlebot parses and renders Javascript, and I came across a couple of interesting things about the way it does so. The first is that Googlebot’s Math.random() function produces an entirely deterministic series. I created a small script which uses this identify Google in an obfuscated fashion:

I was conducting some experiments on how Googlebot parses and renders Javascript, and I came across a couple of interesting things about the way it does so. The first is that Googlebot’s function produces an entirely deterministic series. I created a small script which uses this identify Google in an obfuscated fashion:

The first time Googlebot calls the result will always be , the second call will always be . The script I linked to above simply uses this fact but obfuscates it a little and ‘seed’ it with something that doesn’t look too arbitrary.

Consider the amount of work Google have to undergo to crawl the whole web AND now run Javascript. Optimisations will need to be abundant, and I imagine that having a deterministic random number function is probably:

Googlebot also seems to run Javascript with a sped up clock, which makes sense. Why actually wait 5 seconds when you are a bot? So Google actually runs the timer a lot faster. If you create a simple ticker script and put it through the Google Search Console ‘Fetch & Render’ function it returns almost instantly, but with results looking like this:

The second date is a date from the future! Marty McFly would be proud.

I did wonder if the random number generation sometimes updates, but a Google search for turns up over…

Googlebot’s Javascript random() function is deterministic