You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
Currently, after a link click or a call to goto(), Sapper will immediately history.pushState(). While this provides users an indication they're going somewhere (since we still don't have browsers' default loading indicators, major bummer), I don't know if this is a good behavior overall.
Normally, browsers won't change the URL until a page is somewhat loaded. I don't know at what point exactly they decide it's okay to commit the change (anyone?), but it's definitely not immediate. I'm sure this varies by browsers and versions, but on first glance both Chrome and Firefox only commit the navigation after receiving the first byte of the response body on my machine. This includes redirects, so temporary URLs are never committed.
To test this out, I whipped up a simple test server. Feel free to investigate on different environments:
Sapper does use replaceState for redirects, but it's still clumsy if you have a slow network or the redirect fails. You can see all URLs in a redirect chain and, in fact, if you click a link and while it's loading you click some other link, the never-rendered one will be in your history and, worse, it'll have the original page's title.
I'm not sure on what the best approach for this would be, but I imagine at the very least we could postpone history manipulation at least until preloads settle. This would probably force apps to implement loading indicators if they don't have one, but until (if ever) we get APIs to trigger native browser loading indicators, this is probably a good idea anyway.
Other than that, we could even partly render changes before committing the history, but I have no informed opinion on that for now.
Thoughts?
The text was updated successfully, but these errors were encountered:
Currently, after a link click or a call to
goto()
, Sapper will immediatelyhistory.pushState()
. While this provides users an indication they're going somewhere (since we still don't have browsers' default loading indicators, major bummer), I don't know if this is a good behavior overall.Normally, browsers won't change the URL until a page is somewhat loaded. I don't know at what point exactly they decide it's okay to commit the change (anyone?), but it's definitely not immediate. I'm sure this varies by browsers and versions, but on first glance both Chrome and Firefox only commit the navigation after receiving the first byte of the response body on my machine. This includes redirects, so temporary URLs are never committed.
To test this out, I whipped up a simple test server. Feel free to investigate on different environments:
Test server
Sapper does use
replaceState
for redirects, but it's still clumsy if you have a slow network or the redirect fails. You can see all URLs in a redirect chain and, in fact, if you click a link and while it's loading you click some other link, the never-rendered one will be in your history and, worse, it'll have the original page's title.I'm not sure on what the best approach for this would be, but I imagine at the very least we could postpone history manipulation at least until
preload
s settle. This would probably force apps to implement loading indicators if they don't have one, but until (if ever) we get APIs to trigger native browser loading indicators, this is probably a good idea anyway.Other than that, we could even partly render changes before committing the history, but I have no informed opinion on that for now.
Thoughts?
The text was updated successfully, but these errors were encountered: