HTML 5

HTML 5 introduces the following new features:

  1. Web Workers
  2. Web Storage
  3. Indexed DB
  4. Canvas API
  5. File API
  6. Networking API
  7. Geolocation API

1. Web Workers

W3 Organization Web Workers - http://dev.w3.org/html5/workers/

Provides multithreaded programming in JavaScript:

  • Dedicated workers per owner cannot be shared
  • Shared workers can be shared by multiple owners
  • Workers run in a sandboxed environment and there is no document/DOM access or window access
  • Web workers (and JavaScript) cannot share data across worker threads.

Browser support; IE 10, Chrome 4+, Firefox, TODO

2. Web Storage

W3 Organization Web Storage - http://dev.w3.org/html5/webstorage/

Provides client-side storage of data:

  • Data stored in key-value pairs, as strings and is scoped per (browser) origin
  • Local storage persists data across sessions
  • Session storage discards data when session ends
  • HTML5 spec suggests to use a 5 MB limit per origin, it can be larger if required but the browser may throw a QUOTA EXCEEDED ERR that should be caught in a try ... catch block
  • Browser support; IE 8+, Chrome 5+, Firefox 3.5, TO D

2.1 Local Storage

  • Accessed via window.localStorage
  • Set the language window.localStorage.language = "en-us";
  • Write a value window.localStorage.["counter"] = 100;
  • Write a widget window.localStorage["widget"] = JSON.stringify(widget);
  • Never assume previous values saved to local storage will always be there
  • Never store sensitive data to local storage

2.2 Session Storage

3. Indexed DB

  • Create and open database with indexeddb.open with a database name and a version number e.g. var db = window.indexedDB.open("myDatabase", 1);
  • If database doesn't exist it is created and db.onupgradeneeded is called

4. Canvas API

5. File API

6. Networking API

7. Geolocation API

results matching ""

    No results matching ""