Why sites like twitter, gawker use #! instead of a simple url?

Possible duplicate:
What is shebang (#!) On Facebook and the new Twitter URLs for?

Twitter profiles now have a URL of the form:

http://twitter.com/#!/username 

instead of a simple structure:

 http://twitter.com/username 

What does #! ? What is the advantage of using #! ? I read that this is related to the Google search robot, but I donโ€™t understand how exactly this works.

+4
source share
2 answers

There are two parts:

Why is the fragment identifier instead of the real page?

Because they use Ajax . Instead of linking to a new page, they link to a nonexistent or dynamically generated fragment on the current page, and then use JavaScript to modify the content.

Why start the fragment id with !

Because Google maps it to a different URL so that you can serve a special alternative version just for them. This allows you to index content using search engines.

+7
source

In the URL, the content after the hash mark (#) is not sent to the server, but is displayed in JavaScript on the page. Thus, using # basically allows you to process the page "http://twitter.com/" (for example, by opening background connections to load additional data). It also means that content that does not change from one page to another (think about the general layout of the page) can be cached and served right away (since the effective URL is still โ€œhttp://twitter.com/โ€) whereas to place it on the path to the URL (without a hash), to obtain this layout, a complete separate selection will be required.

+2
source

Source: https://habr.com/ru/post/1339111/


All Articles