Open luavreis opened 2 years ago
@srid recently I'd been facing other issues related to route switching, so I was wondering, what is the reason to do the route switching via JavaScript instead of leaving it to the browser?
Right now I'm using https://github.com/lucasvreis/ema/commit/13dfbeca8d5bda5702378b292d54d057c98df03a that simply removes the switchRoute
code, and now route changes are handled by the browser as usual. The server will disconnect and then reconnect, but I don't see a big issue in this. When you are editing a page, hot reload works as usual. And I think this has advantages:
ema
that attempts to replicate the usual browser behavior, like:
ema
doesn't do this currently)DOMContentLoaded
will fire, the global state is reset. I was writing a script that remembers the open/folded state of headings, it was somewhat difficult to make it work well with switchRoute
, had to use a MutationObserver
. Of course it's about the same trouble as making it work reliably with hot reload, but at least scripts that work in the static site won't simply break when navigating through the live server pages@lucasvreis Fast page load is the main reason (websocket connection is smoother; also morphdom patches only what's changed) that I can recall. I just tried out bin/run
examples with switchRoute
commented out and there is indeed a noticeable delay (along with the orange indicator flashing on top-left) between page transitions. EDIT: with switchRoute disabled, it is worth keeping in mind that the websocket connection is reestablished on each page switch which adds to the delay.
I am not very familiar with the JS reliability issues you are facing, but I can see how that can be problematic with switchRoute even though in my experience it has been fine. Perhaps we can provide an option to disable switchRoute entirely (with it enabled by default). Say a CLI argument like run --port=8080 --disable-switchRoute
(which would also carry over to emanote). How does that sound?
Perhaps we can provide an option to disable switchRoute entirely (with it enabled by default). Say a CLI argument like
run --port=8080 --disable-switchRoute
(which would also carry over to emanote). How does that sound?
Specific proposal somewhat related to this: https://github.com/srid/ema/issues/159
This is just for keeping track of the discussion in https://github.com/srid/ema/pull/86#issuecomment-1044854353. (if the URL being displayed has an anchor, every time the page is patched the client would scroll to the anchor again).
Proposed fix (to the current, non-multisite ema) is: