localStorage vs. Objects

Benchmark created by Nicholas C. Zakas on


Preparation HTML

<script>
  localStorage.setItem("foo", "body { background: blue; margin: 10px; padding: 10px; color: black; text-decoration: none; }");
  
  var FOO = {
   foo: "body { background: blue; margin: 10px; padding: 10px; color: black; text-decoration: none; }"
  };
  
  var value;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Reading from localStorage
value = localStorage.getItem("foo");
ready
Reading from an object
value = FOO.foo;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.