localStorage is synchronous in nature, meaning when it loads it can block the main document from rendering
The answer is that there is no simple solution for storing data on the end users’ machines and we should stop advocating
localStorage as a performance boost. What we have to find is a solution that makes everybody happy and doesn’t break the current implementations. This might prove hard to work around. Here are some ideas:
- Build a polyfill library that overrides the
localStorage API and stores the content in IndexedDB/WebSQL instead? This is dirty and doesn’t work around the issue of the user being asked for permission
localStorage in an asynchronous fashion in browsers – actively disregarding the spec? (this could set a dangerous precedent though)
- Change the
localStorage spec to store asynchronously instead of synchronously? We could also extend it to have a proper
getStorageSpace interface and allow for native JSON support
- Define a new standard that allows browser vendors to map the new API to the existing supported API that matches the best for the use case?
Visit www.divhide.com for more informations, contacts and news about Web Development.
See other blog posts at blog.divhide.com.
Divhide purpose is to follow the HTML5 movement and contribute with applications which prove the quality of technology.
Feel free to contact divhide.