localStorage may be deactivated by setting a config option or using
security-related extensions at least in some browsers, which might
(at least in FF) break backend JS functionality.
So we need an extra check if localStorage is null.
References #306