Nouveaux APIs (HTML5, CSS3, JS)
      23 février 2012 - Rémy Savard
Nouveaux APIs


• HTML5

• APIs

• Stratégie
HTML5

"This logo represents HTML5, the cornerstone for
            modern Web applications."




         W3C - http://www.w3.org/html/logo/faq.html#logo-represent
HTML5

"HTML5 is the next major revision of the HTML
   standard, currently under development."




           Wikipedia - http://en.wikipedia.org/wiki/HTML5
HTML5



HTML
HTML5



HTML + CSS
HTML5



HTML + CSS + JavaScript =
HTML5



HTML + CSS + JavaScript =
APIs
Microdata   APIs
Web Storage

Microdata        APIs
Offline Web applications

   Web Storage

Microdata        APIs
Offline Web applications

   Web Storage          Web Workers

Microdata        APIs
Offline Web applications

   Web Storage          Web Workers

Microdata        APIs        Geolocation
Offline Web applications

   Web Storage          Web Workers

Microdata        APIs        Geolocation

                        Drag & Drop
Offline Web applications

   Web Storage          Web Workers

Microdata        APIs        Geolocation

                        Drag & Drop
                    Video/Audio
Offline Web applications

   Web Storage            Web Workers

Microdata        APIs         Geolocation

                          Drag & Drop
                    Video/Audio
                 Canvas
Offline Web applications

   Web Storage             Web Workers

Microdata         APIs         Geolocation

                           Drag & Drop
            SVG      Video/Audio
                  Canvas
Offline Web applications

   Web Storage             Web Workers

Microdata         APIs         Geolocation

    CSS3                   Drag & Drop
            SVG      Video/Audio
                  Canvas
Microdata

"[...] people understand when they read the web
      pages. But search engines have a limited
 understanding of what is being discussed [...]"




               http://www.schema.org/docs/gs.html
Microdata
Microdata
Microdata
Microdata
Personnes



Événements




Applications


               http://www.schema.org/docs/gs.html
Microdata


Auteurs, critiques, musique, recettes,
 applications, produits, événements
           personnes, etc.
Stockage



• Web Storage

• Offline Web
  applications
Web Storage

 "[...] used for storing data in a web browser. Web
storage supports persistent data storage, similar to
      cookies, as well as window-local storage."




               http://en.wikipedia.org/wiki/Web_Storage
Web Storage

• Stockage clé-valeur dans le navigateur
• 0 info stocké dans la requête HTTP
• 5 Mo de stockage (IE=10 Mo)
• Seulement les strings peuvent être
  stocké (Conversion en JSON pour
  stockage des objets JavaScript)
Web Storage

• Local Storage
 • Données disponibles sur le domaine
 • Persistées après fermer le navigateur


• Session Storage
 • Durée de vie de la fenêtre/onlget
Web Storage
Web Storage
Offline Web
                 Applications

"[...] store resources to be used by the browser when
it’s offline, granting your users partial access to your
                 web site or application."




             http://html5doctor.com/go-offline-with-application-cache/
Offline Web
         Applications



• Méthodes pour fonctionner sans
  connexion réseau
• Contrôlé par le fichier appelé manifeste
Offline Web
        Applications

• CACHE
 • Liste en cache (URLs externe compris)
• FALLBACK
 • Tentative d'accès fichier pas en cache
• NETWORK
 • Disponibles uniquement en ligne
Offline Web
Applications
Offline Web
Applications
Web Workers




"[...] API for running scripts, [...] in the background
  independently of any user interface scripts. [...]"


                 http://en.wikipedia.org/wiki/Web_Workers
Web Workers

• Scripts de longue durée pas
  interrompus par les scripts qui
  réagissent aux autres interactions des
  utilisateurs
• Coût élevé des performances de
  démarrage et de la mémoire par
  instance
Web Workers
Web Workers
Geolocation


"[...] interface to retrieve the geographical location
        information for a client-side device.[...]"




                 http://en.wikipedia.org/wiki/Web_Workers
Geolocation
• Emplacement du
  périphérique grâce
  à la consultation de
  serveurs
  d'informations de
  localisation

• Adresse IP, Wi-Fi,
  Adresse MAC,
  Bluetooth, etc.
Geolocation
Geolocation
Drag & Drop




"[...] event-based mechanism, JavaScript API, and
 additional markup for declaring [...] element be
                draggable on a page."


             http://www.html5rocks.com/en/tutorials/dnd/basics/
Drag & Drop


• Mécanisme basé sur des événements
• API JavaScript
• Balisage supplémentaire pour déclarer
  qu'un élément est déplaçable
Drag & Drop
Drag & Drop
Video / Audio




"[...] Often presented as an alternative to flash in the
media, the video tag actually goes beyond that. [...]"



             http://www.html5rocks.com/en/tutorials/video/basics/
Video / Audio
• Plug-in:
 • Aide à combler les trous sur le web
 • Ne sont pas ouverts
 • Pas créés par la communauté
 • Sous le contrôle des entreprises
• <video> et <audio> sont natifs de
  votre navigateur
Video / Audio
Video / Audio
Canvas




"[...] dynamic, scriptable rendering of 2D shapes and
  bitmap images. [...] Canvas consists of a drawable
                       region [...]"



               http://en.wikipedia.org/wiki/Canvas_element
Canvas



• Région défini en HTML
• Rendus dynamiques d'images bitmap
  via des scripts
Canvas
Canvas
Scalable Vector
             Graphics




"[...] two-dimensional vector graphics, [...] they can
   be searched, indexed, scripted and, if required,
                  compressed. [...]"



             http://en.wikipedia.org/wiki/Scalable_Vector_Graphics
Scalable Vector
         Graphics

• Décrit des graphiques vectoriels
• Basé sur XML
• Peuvent être dynamiques et interactifs
• Des modifications peuvent être décrites
  dans le temps avec JavaScript
Scalable Vector
   Graphics
Scalable Vector
   Graphics
CSS3
CSS3
Media Queries
CSS3
Typograhpie
CSS3
Texte
CSS3
Couleurs
CSS3
Fonds et bordures
CSS3


 Transitions, transformations 2D,
animations, système de colonnes,
    dégradés, sélecteurs, etc.
APIs


Indexed Database, Forms, Device orientation,
    WebSockets, Gestion de l'historique,
      nouveaux sélecteurs JavaScript,
         XMLHttpRequest2, etc.
Stratégie
Support


Stratégie
Support


Stratégie
  Détection
Polyfills               Support


     Stratégie
            Détection
Support
Support
Support
Support




 "10 years ago a browser was born. Its name was
Internet Explorer 6. Now that we’re in 2012, in an
  era of modern web standards, it’s time to say
                    goodbye."

               Microsoft - http://www.theie6countdown.com/
Support
Support
Support
Support
Support




We, as developers, should be able to develop with
 the HTML5 apis [...]. Developing in this future-
  proof way means as users upgrade, your code
doesn't have to change but users will move to the
        better, native experience cleanly."
                    Paul Irish - Google
Support



<!DOCTYPE HTML>
Support
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {

      margin: 0;

      padding: 0;

      border: 0;

      font-size: 100%;

      font: inherit;

      vertical-align: baseline;
}



/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {

      display: block;
}
Support




caniuse.com
Détection
Détection

Créer chaque élément en JavaScript pour Internet
                Explorer 6, 7 et 8
Détection
Polyfills


"So here we're collecting all the shims, fallbacks, and
 polyfills in order to implant html5 functionality in
    browsers that don't natively support them."




        The All-In-One Entirely-Not-Alphabetical No-Bullshit Guide to HTML5 Fallbacks
Polyfills

     The All-In-One
Entirely-Not-Alphabetical
       No-Bullshit
         Guide to
    HTML5 Fallbacks
  The All-In-One Entirely-Not-Alphabetical No-Bullshit Guide to HTML5 Fallbacks
Conclusion
caniuse


Conclusion
caniuse


Conclusion
  Modernizr
Polyfills               caniuse


   Conclusion
            Modernizr
Merci

• caniuse.com
• html5boilerplate.com
• html5rocks
• <html>5 doctor
• Dive into HTML5
• wikipedia (HTML5)
Nouveaux APIs (HTML5, CSS3, JS)
      23 février 2012 - Rémy Savard

Nouveaux apis