4 ms·
> LocalStorage is popular for web apps because it is lazy No... localStorage is popular because it allows you to persist state without requiring a server, open
by throwaway2016a 5y ago
> LocalStorage is popular for web apps because it is lazy
No... localStorage is popular because it allows you to persist state without requiring a server, opening up a whole lot of use cases that would normally require a login. With the tradeoff that you can't easily sync between machines and it can be cleared readily.
Calling it "lazy" seems bit unnecessarily confrontational. Of all the times I have used localStorage on my apps I can't say the reason was even once "laziness."
With that said, it would be nice to keep stats across instances on multiple devices. It adds either a lot of complicated edge cases or a lot of server calls (or both), though and it would need login or some other way to tell the server that Device A and Device B are the same person.
You also lose offline play.
A Progressive Web App would be nice. The best of both worlds. But guess what PWAs often use... localStorage, which I guess is lazy ;)
But I for one think an app that doesn't constantly send my every move to the server is actually a breath of fresh air.
Edit: fixed typo
- nileshtrivedi 5y ago> some other way to tell the server that Device A and Device B are the same person Browsers already have both user identity across multiple devices and ability to sync data. It just needs to be extended to cookies and localstorage.
- kaycebasques 5y agoThe excellent cross-browser support of localStorage and the simplicity of the API should also be appreciated
- realityking 5y agoLocalStorage serves important use-cases - you mentioned a few - but I‘be seen it used a bunch in web apps, where the user is already logged in, to persist setting. It was easier than adding an API to store a user‘s UI settings/state.
- throwaway2016a 5y agoTrue. Not only easier but often times that user wants different settings on different machines (or even different browser profiles). What I want in my settings on my mobile device is not always the same as desktop especially when it comes to visual settings.
- TimTheTinker 5y ago> But I for one think an app that doesn't constantly send my every move to the server is actually a breath of fresh air. I strongly agree. For me as a user, use of localStorage (and its ability to run 100% offline and even be loaded from a local path) makes Wordle particularly charming and usable. It's also the ultimate in zero-trust architecture because there is no back end.
- ocdtrekkie 5y agoHow often do you audit that the app hasn't changed to collect data? The idea LocalStorage-based apps are safe is silly if you're always loading them from a remote server.
- TimTheTinker 5y ago> The idea LocalStorage-based apps are safe is silly if you're always loading them from a remote server. This is true for any web page you load from a server in a browser. My point is that Wordle's developer had to do almost no work to achieve a very high level of security. Literally the only things required are to (a) set up TLS correctly and (b) protect the app's static resources (and the server that's hosting them) from being compromised. Depending on his choice of hosting provider, code repository, and build/deploy, those tasks may have been taken care of automatically.
- yen223 5y agoI am pretty convinced that if Wordle added features that required talking to a server, it would make the overall experience worse, not better. It's easy to take for granted that you never see a loading spinner when playing the game, and that's largely because everything happens client-side. To me, the real takeaway from the success of Wordle is that a lot of features that one might think are important, actually aren't in practice.
- dsr_ 5y agoWordle's stats would be easy enough to encode into a Base64 string that you could then copy and paste into a new one, or save in a text file as a backup... so if you're going to write something along those lines, consider doing that.
- throwaway2016a 5y agoThat could work though it's only a one time transfer (you can't continue playing on both devices unless you keep copying the encoded data). One neat idea I like is using a GUID and having that act as a server key (vs an account) they you can copy the GUID, put it in a URL, have it transferred via QR code, etc. Of course that method then requires server storage.