robinvdvleuten / vuex-persistedstate

💾 Persist and rehydrate your Vuex state between page reloads.
https://npm.im/vuex-persistedstate
MIT License
5.77k stars 378 forks source link

Why is there such a delay in rehydrating? #312

Closed adamchipperfield closed 4 years ago

adamchipperfield commented 4 years ago

Why is there a delay in the page load and the state being rehydrated? For me there is around a second or so. Is there not a way to have this happen pretty much instantly if we are only playing with cookies or local storage?

Would love some input as it’s really bugging me. I’ve thrown up a loading screen until the plugin has rehydrated the store, but not ideal and lighthouse doesn’t like loading screens.

robinvdvleuten commented 4 years ago

how much data are you rehydrating? 10 bytes? 1mb?

adamchipperfield commented 4 years ago

One cookie, for example, is a 1.5kb.

jaythomas commented 4 years ago

@adamchipperfield I hand-rolled my own Nuxt client-side plugin to subscribe to the store and supply identical functionality to this plugin. I can say for certain the delay is Nuxt's issue and not this plugin. How I get around the UX issue is to hide the elements on the page that absolutely depend on the state but allow the page and most of the content to go ahead and load. The only solution I know around this is to stop using Nuxt. Vue-Cli is a very nice (official) alternative to Nuxt's CLI. There's even an SSR plugin for it now.

robinvdvleuten commented 4 years ago

Thank you for figuring this out @jaythomas. Glad to know that the delay is coming from Nuxt instead of this plugin!