As others have said, it's to show the data without reloading the page. They could of course do it without actually adding anything to the url - but then it won't be bookmarkable (and refresh would get you back to a page without results). They could use the new history pushstate api, but then: 1. it won't work in older browsers 2. if they wanted it to work in older browsers they'll have to shim it (which ends up using…
Why would google.com/?q=search-term not be bookmarkable?
Ask HN: Why does Google put the query in the URL hash instead of query string?
51–60 of 71 posts
Re: Ask HN: Why does Google put the query in the URL hash instead of query string?
#52I had always assumed they did this for financial reasons. The hash won't be sent along as part of the referrer header, so the search query won't be available to 3rd party analytics. The only way to track search queries is to use Google's own analytics, which can correlate queries to traffic since it's watching both ends of the handoff. The technical explanation discussed in this thread is certainly valid. But it only…
Re: Ask HN: Why does Google put the query in the URL hash instead of query string?
#53I had always assumed they did this for financial reasons. The hash won't be sent along as part of the referrer header, so the search query won't be available to 3rd party analytics. The only way to track search queries is to use Google's own analytics, which can correlate queries to traffic since it's watching both ends of the handoff. The technical explanation discussed in this thread is certainly valid. But it only…
There are good technical explanations of the behaviour in the comments. And the observed behaviour is that only subsequent queries get put in the hash instead of the query. The why is also addressed by the comments (IE only got support for pushState after the solution was already built). Besides, for a long time, Google added intermediate pages when you clicked through a search result, adding the appropriate referrer…
Re: Ask HN: Why does Google put the query in the URL hash instead of query string?
#54Earlier quoted context omitted.
They could use `pushState` to change the query without reloading the page?
They could if they were building it now. IE got pushState support in IE 10 in 2012. The hash state has been there since Instant Search was launched in 2010.
Re: Ask HN: Why does Google put the query in the URL hash instead of query string?
#55Earlier quoted context omitted.
They could if they were building it now. IE got pushState support in IE 10 in 2012. The hash state has been there since Instant Search was launched in 2010.
Graceful degradation/progressive enhancement is a thing, though.
Not to mention, why fix something that isn't broken? There are cases for it, but it's roughly the same tech that it was 4 years ago. What would they gain by spending developer time on it?
Re: Ask HN: Why does Google put the query in the URL hash instead of query string?
#56Earlier quoted context omitted.
They could if they were building it now. IE got pushState support in IE 10 in 2012. The hash state has been there since Instant Search was launched in 2010.
Graceful degradation/progressive enhancement is a thing, though.
Re: Ask HN: Why does Google put the query in the URL hash instead of query string?
#57Earlier quoted context omitted.
Yes, and if you're using Firefox, you can this with the knowledge of its Smart Keywords to create super quick shortcuts! https://support.mozilla.org/en-US/kb/how-search-from-address... For example, I directly go to Wikipedia's page on "India " by typing wp India in my address bar using these search keywords, or search images of birds on google by typing gi birds in it. (There's a rather cumbersome way to do the same…
It's not that cumbersome in Chrome. Right click the URL bar -> "Edit search engines" -> Find the search engine you'd like to easily search, double click the second column and enter a keyword for it. For example, for wikipedia, I have "wp" as a keyword. In the URL bar, you can just type "wp " and you can search wikipedia.
I have some specific shortcuts like wdir (walking directions from my home address) and some shortcuts that allow me to quickly jump to subsections of specific sites.
Re: Ask HN: Why does Google put the query in the URL hash instead of query string?
#58Earlier quoted context omitted.
Graceful degradation/progressive enhancement is a thing, though.
The amount of money Google makes supporting older browsers is most likely measured in billions. Not to mention, why fix something that isn't broken? There are cases for it, but it's roughly the same tech that it was 4 years ago. What would they gain by spending developer time on it?
Re: Ask HN: Why does Google put the query in the URL hash instead of query string?
#59Re: Ask HN: Why does Google put the query in the URL hash instead of query string?
#60Earlier quoted context omitted.
They could use `pushState` to change the query without reloading the page?
Would that not remove the possibility for sharing or manually editing the URL? (I'm asking because I don't know how much cool stuff pushState can do.)
Manually editing the link causes that same fetch-render-refetch flow.
Edit: Oh, you were asking about pushstate. No, that specifically fixes the problem with the double fetch, so long as the server side and client side do the right thing to make the user see the same page for the same URL.
Pushstate just lets the JS client modify the URL without triggering a page reload, so the client can change the actual query param instead of the hash.