YUILibrary - Open source JavaScript and CSS for building richly interactive software.
Fork YUI on GitHub
  • Home
  • Gallery
  • Forums
  • YUI 2
  • YUI 3
  • YUI Compressor
  • YUI Doc
  • More
  • Gallery Forums
  • Gallery Stats
  • Gallery Calendar
  • Register
  • Login

Modules

  • Home
  • Featured
  • Popular
  • New
  • All

Documentation

  • FAQ
  • Developer FAQ
  • Developer Guide
  • Module Setup

Tag Cloud

filter overlay node event jafl rgrove plugin caridy html5 lsmith foxxtrot form slideshow ericf skinnable widget animation jsonp port nzakas apipkin adam yui2 davglass ajax io

Context Navigation

    YUI Library is not responsible for bugs or support with this module. It is available as a free service. For support please contact the module owner with the provided links.

    Storage Lite (gallery-storage-lite) on cdn

    Last Updated: 02/20/10
    + 1 -

    Ryan Grove

    YUI Developer

    See 2 more by this user.

    Featured Item

    Created: 02/20/10
    Last CDN Push: 02/22/10
    Build Tag: gallery-2010.02.22-22
    Project: YUI 3
    License: YUI BSD
    YUI Version: 3.0.0
    Free for use.

    Storage Lite provides a lightweight YUI 3 API for persistent cross-browser local key/value storage similar to the HTML5 localStorage API. Supported browsers include IE6+, Firefox 2+, Safari 3.1+, Chrome 4+, and Opera 10.5+. No browser plugins are required (not even Flash).

    Storage Lite will automatically use the best available local storage API supported by the browser it's running in. The complexities of the following storage APIs are all wrapped in a loving YUI 3 embrace and presented to you as a single consistent HTML5-like API:

    • Firefox 3.5+, Google Chrome 4+, Safari 4+, IE8, Opera 10.5+: HTML5 localStorage; these modern browsers all support the core localStorage functionality defined in the HTML5 draft.
    • Firefox 2.x and 3.0.x: Gecko globalStorage, an early API similar to HTML5's localStorage.
    • Safari 3.1 and 3.2: HTML5 Database Storage, because Safari 3.1 and 3.2 don't support HTML5 localStorage.
    • IE6, IE7: userData persistence, a rarely used IE feature for associating string data with an element on a web page and persisting it between pageviews.

    When minified, Storage Lite weighs in at about 2.6KB before gzip, making it ideal for performance-critical web apps that need client-side storage capabilities across all A-grade browsers and can't depend on non-standard browser extensions.

    • Tags:
    • database
    • rgrove
    • storage
    • html5
    • localStorage
    • userdata
    • Download
    • Docs
    • Homepage
    • Bugs
    • Source
    • Example
    • Forum
    • History

    Code Sample

    <script src="http://yui.yahooapis.com/3.1.0/build/yui/yui-min.js"></script>
    YUI({
        //Last Gallery Build of this module
        gallery: 'gallery-2010.02.22-22'
    }).use('gallery-storage-lite', function (Y) {
     
        // For full compatibility with IE 6-7 and Safari 3.x, you should listen for
        // the storage-lite:ready event before making storage calls. If you're not
        // targeting those browsers, you can safely ignore this step.
        Y.StorageLite.on('storage-lite:ready', function () {
     
            // To store an item, pass a key and a value (both strings) to setItem().
            Y.StorageLite.setItem('kittens', 'fluffy and cute');
     
            // If you set the optional third parameter to true, you can use any
            // serializable object as the value and it will automatically be stored
            // as a JSON string.
            Y.StorageLite.setItem('pies', ['apple', 'pumpkin', 'pecan'], true);
     
            // To retrieve an item, pass the key to getItem().
            Y.StorageLite.getItem('kittens');    // => 'fluffy and cute'
     
            // To retrieve and automatically parse a JSON value, set the optional
            // second parameter to true.
            Y.StorageLite.getItem('pies', true); // => ['apple', 'pumpkin', 'pecan']
     
            // The length() method returns a count of how many items are currently
            // stored.
            Y.StorageLite.length(); // => 2
     
            // To remove a single item, pass its key to removeItem().
            Y.StorageLite.removeItem('kittens');
     
            // To remove all items in storage, call clear().
            Y.StorageLite.clear();
     
        });
     
    });

    Forum Posts

    Subject Author Date
    Article introducing Storage Lite Eric Miraglia 02/26/10
    Re: Article introducing Storage Lite Andrew Wooldridge 03/9/10
    YUI Projects
    • All YUI Downloads
    • YUI 2
    • YUI 3
    • YUI Doc
    • YUI Compressor
    • YUILibrary.com
    • YUI Build Tool
    • YUI PHP Loader
    Pages & Links
    • All YUI Downloads
    • Git FAQ
    • Graded Browser Support
    • Contribute to YUI
    • Forum Stats
    • Gallery Stats
    • YUI Calendar
    Contribute
    • Submit a Bug
    • Request a Feature
    • Write Code
    • Meet the Team
    Follow YUI
    • on GitHub
    • on Twitter
    • on FriendFeed
    • on Facebook
    • on IRC
    • YUI Blog
    • YUI Theater
    • YUI Forums

    © 2010 YUI Library - Site Credits