It really can be realized really simply. Suppose you have a link on your web page.
<a id="mylink" href="/new-url">My link</a>
You can override its behavior by returning false
from the event handler:
document.getElementById("mylink").onclick = function (event) { window.history.pushState({urlPath:'/new-url'}, "", "/new-url");
Using this method, you can only do part of the page reload when you click a link.
Edit
I believe that youtube does not listen to location changes. This is because if you are actually calling
window.location = '/watch?v=notrelevant'
The webpage is still being updated.
source share