Further Exploration
The <canvas> HTML5 is an exciting technology, one that offers considerably more
than I have had a ch ance to put on these few pages. You c an also use a canvas to work
with other graphic elements such as patterns, curves, pixels, text, and images. You
can make elements transparent, add shadows, and you can apply coordinate system
transform ations. And yes, you can d etect mouse clicks over certain areas of the c anvas
to create interactive graphics. I therefore encourage anyone who feels he/she could
make a great use of this tempting techn ology to search among countless sources of
informa tion to find out more about it. For example, the book
HTML5 Canvas by Steve
and Jeff Fulton offer s a decent start.
B.2 Local Data Storage through Web Storage
As soon as you’re connected to the web , there are two places where you can store
your data: on the web server (server-side) or on your own computer (c lient-side).
Both have their pros and cons, and you ’ll learn which type of storag e works best for
which purpose as you progress in your web programming proficiency. However, as
you can read in the paragraph about security concerns later in this section, sensitive
data definitely belongs to a web server and not to a client computer.
Web application s and even web documents can imp rove tre mendously if you furnish
them with some client-side memory. You ca n program web pages to stor e data such
as user preferences or even save the complete state of the page, so y our visitor al-
ways finds a page exactly as he/she left it at the end of his/her last visit. In the early
days of the Internet, storing user data was on ly possible on a server. This was soon
recogn iz ed as a drawback because of excessive storage a nd retrieval load on servers
for tasks that could b e managed locally by a client. As early as in 1994, Netscape
Communica tions used cookies (a type of client-side data storage) to implement a re li-
able virtual shopping cart to store items a user selected f rom different pages of a site,
possibly across multiple visits. Online shopping sites today almost exclusively store
selected items in a database on the server side. For many web applications, however,
local data storage capability has become indispensable, especially when it comes to
running web applications offline. This makes web applications look and feel more like
real applications.
For a long time, cookies were the only c lient-side data storage mechanism arou nd.
However, they were d esigned for use by ser ver-side scripts and it was quite awkward
to utilize them from client-side programs. As the HTML 5 Web Storage API became
universally available, cookies slowly turned back to their initial role as a client-side
storage instrument for server-side scripts.
Apart fr om the Web Storage, there exist some other local storage technologies, but
none of them succeeded in getting the level of standardization that Web Storage did.
The poten tially exciting Filesystem API, conceptualized to work with a private local
filesystem utilizing file-based stora ge mech anisms familiar to most programmers, was
pronounced dead in April 2014 because of little inte rest shown by the majority of
browsers. Also of interest was a client-side database support, w hose standardization
efforts also failed and tha t is n ot implemented equally in all browsers.
B.2. Local Data Storage through Web Storage 279