O'Reilly logo

Instant HTML5 Local Storage How-to by Alex Libby

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building a simple plugin using jQuery (Should know)

Up until now, we've worked with Local Storage directly in our code. While this will work perfectly well, it's not an ideal solution; it improves messy code if it is held inline, and adds a lot of unnecessary code to a site. A better option is to separate the code and turn it into a plugin that we can re-use; we will see how we can build a simple plugin as part of this recipe.

Getting ready

For this recipe, all you will need is your text editor. Anything else that is required is called directly from within the code.

How to do it...

Perform the following steps, to build a simple plugin using jQuery:

  1. Let's begin with adding the following code snippet to a new HTML document, and save it as basicplugin.html ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required