Search code examples
javascripthtmlsearchgoogle-search

How does Google hide HTML source of search results?


When you try to view the source code of a Google search results page you just see a bunch of javascript code instead of readable text. How does Google do that?

I have searched through the web but couldn't find a good explanation, only thing I found was this: http://goo.gl/FIvD6 and it is not really helpful.

I am not a web developer but I just got curious. A brief explanation would be nice. Thanks.


Solution

  • Google builds the DOM with the javascript you noted. It does this for a number of reasons:

    • Decrease the load on the server to generate each dynamic result set with HTML markup.
    • Google returns the results in a JSON feed (example) - pastebin. Less processing power is required to produce the JSON response than a full HTML snippet or completely new page
    • Speed. Assuming that the user has a decent internet connection, the speed of the pages rendering on the client side compared to the server side is negligible.

    As suggested above, jump into firebug and have a look around :)