Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> it clears scrolling state by browser back

Twitter handles this masterfully (or used to)

> or page refresh.

Technically you can use history.replaceState to store, ahem, state on the "current page", so nothing stops you from saving a cursor there to use when loading the content.

The issue with infinite scroll is that very few people know how or care to "make it work correctly"



I wish browsers did this as a default option. The back button should never have a noticeable delay.


They do if you use non-ajax navigation: the scroll position is preserved and so is the document as last seen: https://web.dev/bfcache/

But once you call history.pushState, the browser is relinquishing control to you. At that point, going “back” only changes the URL, as far as the browser is concerned, and that part is instantaneous.




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

Search: