views:

58

answers:

2

Facebook is doing Ajax History (Back and Forward button) and Bookmark using #! instead of just # in the URL. Is it always a good idea to do that, because I was thinking that a usual anchor could interfere with the Ajax History mechanism to trigger it into processing a normal anchor.

So, the Ajax History function will only process a hash portion only when it sees #! instead of just #.

And is using ! compatible with major browsers? If Facebook is using !, a guess is that it may be fairly well supported.

+2  A: 

In regards to usability on your website, it doesn't matter and you can use anything you like.

In regards to search engine optimization, having it and not having it both provide different avenues to go down.

For instance, Facebook uses the ! according to the Google Proposal for Making Ajax Applications Crawlable. Adding the ! will tell google that it should listen in on that ajax request and add that url to search engine results. This is great for websites which have already implemented ajax, as all you need to do is add the !.

The downside of this is that it only solves the problem of making your ajax crawlable. It does not solve the problems of:

  • Keeping the URLs clean and consistent for Ajax and Non-Ajax users. Eg. you could end up with www.facebook.com/profile.php?pid=123#!profile.php?pid=123
  • Keeping the website accessible by Non-Ajax users.
  • Keeping the URLs the same for both Ajax and Non-Ajax users.
  • Requires some severely complicated server side changes for escaping and translation of states in regards to query strings.
  • It is not compatible with the new HTML5 PopState functionality which is designed to truly solve these problems.

For websites which don't currently use ajax for everything, due to the problems above it is far better NOT using the Google Proposal as it is only workaround for sites like facebook which went ajax crazy and needed a desperate solution to SEO. There are alternatives which solve more of these problems (and with the HTML5 PopState now available can solve all the problems). One such alternative is jQuery Ajaxy (as seen on balupton.com) which works by simply upgrading your website into a ajax application, while keeping the experience for a Ajax-Enabled rich and interactive and continuing to work perfectly for Ajax-Disabled users.

balupton
+2  A: 

See Google's Making AJAX Applications Crawlable for a possible use case (don't know if this is why Facebook used this fragment).

Igor Klimer