Yeah. This is a difficult problem to solve and it doesn't seem like any website gets it right all of the time across all devices from what I've seen
To come back to this: one of the difficulties is maintaining "back button" functionality if one gets caught up in hardcore JS solutions.
Not just websites. Chrome on Android does this. It loses its scroll position in its tab tile list when switching between viewing the list and viewing a tab.