Skip to content Skip to sidebar Skip to footer

Is Localstorage Fully Loaded Only After Dom Is Ready?

I have got a bug with some javascript code that it's hard to reproduce (so no jsfiddle, sorry). Exactly the same browser (FF 37.0.2), but two different machines, and I can only rep

Solution 1:

localStorage is not something that needs to be "loaded" asynchronously. It is available the moment the page starts to load and can be used by Javascript anywhere in the page. If the browser has to fetch values form somewhere (e.g. the disk), that is done synchronously when you request the data or before.

There is no need to wait with $(document).ready() before accessing localStorage. The cause of your issue must be something else.

FYI, you can read the spec on WebStorage here: http://dev.w3.org/html5/webstorage/#dom-localstorage. There is no indication in the localStorage section of that document that JS code must "wait" before accessing.

Post a Comment for "Is Localstorage Fully Loaded Only After Dom Is Ready?"