Reputation: 503
I've seen some websites that, once you click on a link, appear to load a page before you're redirected so that the page is displayed instantly, with some sort of bar showing the progress of the request. How do they go about doing this?
Upvotes: 1
Views: 1712
Reputation: 440
It can be done using Ajax. Check out this article which shows how it's done: https://onextrapixel.com/loadingbar-js-adding-a-youtube-like-loading-bar-to-your-website/
It can also be done using the HTML5 History API(which is actually used by YouTube), it adds and removes page URLs into and from the History stack. The URL's from this stack is then used to load the pages using Ajax.
Read more about it here: Curious about the new way YouTube is loading pages
Upvotes: 1