Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update localStorage use? #737

Open
nexushoratio opened this issue Jun 5, 2024 · 0 comments
Open

Update localStorage use? #737

nexushoratio opened this issue Jun 5, 2024 · 0 comments

Comments

@nexushoratio
Copy link
Contributor

While working on a personal plugin, I noticed this bit from MDN's Using the Web Storage API:

Note: It's recommended to use the Web Storage API (setItem, getItem, removeItem, key, length) to prevent the pitfalls associated with using plain objects as key-value stores.

So I switched my code over to it. Out of curiosity, I checked the main code base:

$ find -type f -exec grep 'localStorage\.' {} + | wc -l
19
$ find -type f -exec grep 'localStorage\[' {} + | wc -l
88

(only one came from external source)

Would it make sense update all direct property usage of localStorage to using the methods, just for best practices? Then maybe update whatever linter configs to catch that (if possible) ?

I know, a small thing, but since I just did it myself, I thought I would ask.

Also, I wonder if it would make sense to offer any IITC helper functions? In particular, anything that might detect quota issues and pop up an alert, rather than each bit of code (that currently does NOT do that), having to do so themselves.

I did see an issue about possible alternatives to using localStorage directly (#230). It seems like nothing moved forward on it, and I wonder if it is still an issue with modern browsers. With my plugin, I also managed to max out the quota, but I didn't notice any slow down related to large rewrites. But, I don't use mobile, so not sure if it is problematic there, and such a library migration might still make sense (over my thought).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant