How AJAX is done in github source browse?

You have to use HTML5’s pushState() method to change browser history.

window.history.pushState(data, "Title", "/new-url");

Doc says:

pushState() takes three parameters: a state object, a title (which is
currently ignored), and (optionally) a URL.

The last argument is the new URL. For security reasons you can only change the path of the URL, not the domain itself. The second argument is a description of the new state. And the first argument is some data that you might want to store along with the state.

Leave a Comment