Question

I have a single page app. and just realized that if I replace my location.hash approach to change state with a query approach I would simplify the app. and get the history (back button) for free. (rather than listening to onhashchange events)

So my urls would move from

http://.../spa.html#state={...}
http://.../spa.html?state={...}

The disadvantage is that moving from '#' to '?' implies that the page gets reloaded (which is fine because the state is retrievable) but, although I can see it, it could take longer and/or flicker.

Are there any best recommendation on this ?

Was it helpful?

Solution

That’s kind of the point of an SPA (or at least a major part of it)—to improve the user experience by not having to reload the page. You’re not doing traditional pre-rendered document exchange anyway, which means non-JavaScript-enabled agents are out of the picture already. Thus, with your solution, you’re trading off a major user experience boon for a minor simplification in your code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top