HACKER Q&A
📣 sam0x17

Why does Google use server side rendering for search results?


I've been wondering this for a while.

My thought is that search results could be rendered faster using an SPA-style setup as the rest of the page wouldn't have to be reloaded, yet Google Search still uses server side rendering on their results in 2020.

Is there any particular technical reason they are doing this?

My thoughts on possible reasons are:

* they want to support browsers that have JavaScript disabled and/or older browsers / TOR

* legacy reasons -- their whole infrastructure is designed to deliver results via server side rendering and it would be a pain to change it

* they are in general afraid to make sweeping changes to google search (don't fix what isn't broken)

* some interesting technical advantage of server side rendering in this scenario over client side rendering that I am unaware of but would be curious to learn about


  👤 montroser Accepted Answer ✓
Because it's faster! Which one do you think will render first?

- Send a small amount of HTML and CSS for the browser to show on the page; or

- Send a JavaScript application framework and JSON results, then have the browser interpret the JavaScript, parse the JSON, generate the HTML and show on the page

With an approach like Svelte takes, you can make the second option pretty workable, but you'll still never beat sending markup directly if your goal is to render a small amount of static content as quickly as possible.


👤 thehappypm
The average Google user is more likely to be someone running Microsoft Edge on a 6-year-old cheap PC, than Chrome on a 1-year old Macbook. An SPA requires the front-end do the heavy lifting, spinning up tons of Javascript. Server-side rendering means the browser doesn't have to do a lot of work -- just render the damn HTML, which is fast and efficient. Google results pages are not very hugely interactive compared to say Facebook, so it's better to keep the browser happy to make the page load quickly.

👤 PaulHoule
One issue is that they don't want to provide a well defined api to get search results. The last thing they want is for SEOs to practice the quantitative methods that they expect you to use for adsense.

👤 qpiox
First reason is the one that is most likely. There are many kinds of users on the WWW and they use many kinds of web browsers. So the only constant they all recognize is HTML and the only way to realize an application over the web that will be accessible to all those users, is by rendering it as HTML completely on the server.

Also, from technical point of view there is no point in generating JSON output (or any other format), and use that format by a JavaScript based processor to generate HTML, when you can directly generate HTML that will be as simple as the JSON. There are not many savings. Why?

3 results of a simplified query engine output in HTML: [DIV class="results"]

  [DIV class="result"] [DIV class="url"]URL[/DIV] [DIV class="description"]description[/DIV] [/DIV]

  [DIV class="result"] [DIV class="url"]URL[/DIV] [DIV class="description"]description[/DIV] [/DIV]

  [DIV class="result"] [DIV class="url"]URL[/DIV] [DIV class="description"]description[/DIV] [/DIV]
These results are usable as is, the browser will render them and does not need anything else to do it.

3 results of a simplified query engine output in JSON:

  "results": [
    {
      "url": "URL",
      "description": "DESCRIPTION"
    },
    {
      "url": "URL",
      "description": "DESCRIPTION"
    },
    {
      "url": "URL",
      "description": "DESCRIPTION"
    }
  ]
This output does not save much space. It is equally as complex on the server-side.

But this output is not usable by the user as will not be displayed in a usable form, so you need JavaScript code to process it and generate HTML that will be usable.

So why generate the same list of things two times? It is better, easier and more accessible for the user if you generate HTML the first time.

Just my opinion. This might not be the real reason.


👤 antoineMoPa
I imagine most people pop a new page for every google search, reloading the whole page anyway.

👤 ornornor
Simple: it’s for SEO so that when google crawls the page it shows exactly as they want it indexed. Waaaaait a minute?!

👤 alt_f4
It's because SPAs are a fad and server-side rendering is both faster and better for the client.

👤 sam0x17
one theory I had -- I wonder if doing SSR makes it easier to emit results one by one as they come in vs. an AJAX request where normally you don't get anything until you have the whole response body. Thoughts?

👤 mthoms
Related question —

Why on Earth are are Google results pages non-responsive?


👤 buboard
conserves battery life