Hacker News new | past | comments | ask | show | jobs | submit login

In the article it does state that the history API could be used and why it wasn't.

The first point about updating the whole URL is easy to render moot: when you push new state using the history API, replicate the effect of location.hash by making sure you only change the hash part.

The second part is the sticky one for the "ain't this cool" factor: the throttle in some browsers effectively limits constant animation to 3fps. This isn't an issue for things like the video progress example though: that only needs to update once per second. If you made a library to wrap this idea for easy reuse you could easily implement change detection and other rapid change throttling to smooth things out (so short bursts of many updates work, but longer bursts don't cause a complete stop until ~30s has passed) rather than having to implement these for each use of the technique. ("if" and "you could", because who in their right mind actually would?!)




All I know is he tried pushState. Perhaps replaceState is not throttled, because it doesn't create new history entries, just replaces the last one.

Try this in chrome console. And yes, it doesn't throttle at all.

i=0; setInterval(() => history.replaceState('', '', '/' + (i++)), 50);

It's interesting how people will just believe everything, even if the test is 30 seconds away.


I'm pretty sure Chrome has different behavior with Dev Tools open and Dev Tools closed, and also with what it does with code posted in the console and code run as part of the page.

So just because it is not throttled when run in the console doesnt necessary imply it wont throttle as part of a regular page as well.


It does not in this case. It's just not throttled.


I just tested, Safari still throttles history.replaceState().


I tried this and it still seems to flood my browser history. I can use the back button properly now though.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: