Since cookies are server-side and Localstorage are client-side, what is the fastest for a user to receive?
You start with the wrong assumption. Cookies are stored on the client side. Both localStorage and cookies are stored on the client side.
However, the difference, and that cookies can be set, is managed by the server. localStorage only works on the client side.
I assume that if the client machine is slow, are cookies faster? Or does it make no distinction [sic]?
They are such an easy operation. I would not worry about speed.
Productivity between them is not a factor for its choice. These are your needs.
Cookies:
- For a long time they worked in browsers. Every modern, but not very modern browser to support the browser.
- Access to and management of the server.
- Usually limited to a few kilobytes, depending on the browser.
LocalStorage:
- This is a relatively new concept. Not all browsers support it. For example, IE 6, 7, and you're out of luck.
- Not available from server side. You can make an AJAX call to the server with the data stored in localStorage.
- You have a W3C recommendation of saving 5 MB.
How can I do it faster?
I donβt think anyone can introduce a performance issue right away. Other issues, such as waiting for the DOM to be ready while waiting for script files to load; etc. may slow down.
source share