HTML and CSS Reference
In-Depth Information
Chrome and Opera will allow you to retrieve items set before going into incognito mode,
but once private browsing commences, localStorage is treated like sessionStorage
(only items set on the localStorage by that session will be returned).
Firefox, like Chrome, will not retrieve items set on localStorage prior to a private
session starting, but in private browsing treats localStorage like sessionStorage .
To be safe, always do a series of checks before using localStorage or sessionStorage :
function isLocalStorageSupported () {
try {
var supported = ( 'localStorage' in window &&
window [ 'localStorage' ] !== null );
if ( supported ) {
localStorage . setItem ( "storage" , "" );
localStorage . removeItem ( "storage" );
}
return supported ;
} catch ( err ) { return false ; }
}
Who's Using Web Storage?
Take a look at Table 6-1 , an overview of the five most visited sites on the Internet, to get
an idea of which sites are (or aren't) using Web Storage to optimize.
Table 6-1. Web Storage Survey
Website
Desktop
Mobile
Google Search
Yes, 87K
Yes, 160K
Yahoo!
No
No
Wikipedia
No
No
Twitter
Yes, less than 1K
Yes, 46K
Amazon
Yes, less than 1K
No
For mobile, Google's basic search page is making the most use of localStorage by
storing base64 images and other CSS. For each subsequent page request, it uses Java‐
Script to insert <style> blocks just after the page title in the document head with the
CSS values from localStorage ( Figure 6-4 ).
Figure 6-4. Google's use of localStorage on mobile
 
Search WWH ::




Custom Search