0

On other sites, when you click a link for example, the page goes blank for a second and you see a loading indicator in your browser tab. However, on sites like YouTube and Twitch, when you click a link, you are sent to the page without the loading indicator with no white screen at all.

How is this done? I know it's related to Ajax, but what would be a modern approach to this?

docyoda
  • 121
  • 8

2 Answers2

2

It's called SPA - single-page application. The content of the page is rewritten without reloading. The content is being fetched in the background using ajax and then applied to the page with a bit of help from a frontend framework.

If you want to know more just google for single-page application.

marzelin
  • 10,790
  • 2
  • 30
  • 49
2

You can change the URL in the address bar without causing a page reload using the History.pushState API.

history.pushState(state, title, url);

Soc
  • 7,425
  • 4
  • 13
  • 30