0

I've noticed that Facebook SOMETIMES uses a hash in the url. For example, when I'm on my home page, and then I click my profile page, the URL quickly changes to:

facebook.com/#_________

followed by some other stuff.

before quickly loading to:

facebook.com/profileName

It doesn't always do this. What's going on here?

1 Answer 1

3

The "#" allows you to target something in a web-page. as in

...
<div id="foo"></div>
...

to target foo div in a page you can just do #foo

That being said there is no need to reload the page if you just change the # in the url, and facebook uses this as a hack. What they do is they just change the hash 'which makes the url bookmarkable' at the same time they can load up assets using XHR and the page doesn't reloads itself providing a seamless experience to the user on the other hand it doesn't make as many HTTP requests to the server for CSS / HTML / JS files (despite of being cached the validation is required) and hence reducing the amount of content they have to render and number of HTTP requests to their server, they also can increase the performance and reduce latency of the website doing so.

There is though a better way to do this which is documented in the HTML 5 History API( Which you should read perhaps ) Which allows you to change the URL in the address bar by pushing history states.

2
  • You missed an important part of the question: before quickly loading to: facebook.com/profileName - they are using the History API.
    – Izkata
    Commented Aug 16, 2013 at 18:09
  • The last paragraph of my answer explains Commented Aug 29, 2013 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.