4 ms·
So make this your storage module: // For a given domain, localStorage uses the same permissions as cookies. When // cookies are blocked, attempts to acces
by gavinpc 10y ago
So make this your storage module:
// For a given domain, localStorage uses the same permissions as cookies. When
// cookies are blocked, attempts to access localStorage will throw a Security
// exception. We do that test once here so that we can safely test for this
// object everywhere else.
define(function() {
try {
var K = '__test', V = 1, s = window.localStorage;
if (s) {
s.setItem(K, V);
if (V == s.getItem(K)) {
s.removeItem(K);
return s;
}
}
} catch(e) {}
return null;
});
I mean, I like javascript too. But whether or not your site is rendered entirely by javascript, you should be feature testing for localStorage.
And if your site is rendered entirely by javascript,
(1) it's impossible that rendering to a first-time visitor can depend on something previously stored there.
(2) your site will be hosed by any uncaught error during load
For this to happen on an essentially static page is just laughable.
/rant. Okay, I'm good until 2020.