If you use the iframe and postMessage solution only for this particular problem, I think that it can be less work (both by code and by calculation) only with storing data in a file with a subdomain and if it is not already in localStorage when when downloading, take it from the cookie .
Pros:
- No additional iframe or postMessage settings required.
Minuses:
- Allows you to make data available in all subdomains (not just www), so if you do not trust all subdomains, they may not work for you.
- Sends data to the server for each request. Not really, but depending on your scenario, perhaps even less work than the iframe / postMessage solution.
- If you do, why not just use cookies directly? Depends on your context.
- Cookie size 4K max, total for all cookies for the domain (thanks Blake for pointing this out in the comments).
I agree with other commentators, but it seems like this should be a specific option for localStorage, so jobs are not required.
Matt Jan 22 '15 at 18:05 2015-01-22 18:05
source share