3

Just wondering what are the actual benefits of using HTML5's sessionStorage when storing HTML content to be used in a Javascript carousel?

Is it performance related? Load Times? Bandwidth?

Aran
  • 3,298
  • 6
  • 32
  • 33
  • Cross-linking similar thread "When should I use sessionStorage?" - https://stackoverflow.com/questions/8498357/when-should-i-use-html5-sessionstorage – Devin Rhode May 20 '21 at 19:12
  • 2
    Cross-linking similar thread [When should I use html5 sessionStorage?](https://stackoverflow.com/questions/8498357/when-should-i-use-html5-sessionstorage) - voted to close this as duplicate. The other thread has more info imo. – Devin Rhode May 20 '21 at 19:13

3 Answers3

7

Yes you'll use less bandwidth, it'll be better for performance because you can store information in your browser up to 5Mb. It's much more than with cookie.

For instance to set an item in the storage you can do:

sessionStorage.setItem("name1", "value1");

and to get the item

sessionStorage.getItem("name1");

The sessionStorage is relative to each subdomain/domain.

sebarmeli
  • 17,949
  • 7
  • 35
  • 40
  • 1
    I just tested Firefox 3.6.12 Mac, and I was able to put at least 60MB into `sessionStorage` without issue. `localStorage` has a 5MB limit, but not `sessionStorage`. – nickf Nov 16 '10 at 12:52
  • Yeah you're right, 5mb is quite standard for localStorage, for sessionStorage different browsers (mobile and not) have different behaviours. I would suggest to use 5Mb though as guide line. – sebarmeli Nov 23 '10 at 00:21
1

Yes. sessionStorage stores much more information than cookies can, and it is easier to access as well.

By storing data you need to access again locally, you avoid (or minimize) ajax calls, and in turn server and database loads.

This will result in faster page loads (as you will not need to wait for the server to provide the data), and bandwidth (as you have minimized communication with the server).

kingjeffrey
  • 14,894
  • 6
  • 42
  • 47
0

Theoretically (and probably actually in most cases), faster load time, as it is almost like the images are already cached (loading from the user rather than the server). I don't know much about it, but had looked into whether it would help as a storage for images on https connections. It did not help there (and in fact, may have made it worse).

ScottS
  • 71,703
  • 13
  • 126
  • 146