SlideShare una empresa de Scribd logo
1 de 54
Descargar para leer sin conexión
The Mobile Web - HTML5 on mobile devices
HTML5 User Group - Atlanta
By: Wesley Hales
@wesleyhales
Wesley Hales
• Senior Developer at Red Hat           @w
                                          esle
• W3C Member                                  yha
                                                 les
• JSR 301/329 Rep.
• HTML5 User Group Founder
• html5rocks.com, DZone Refcard, and author of
  many other articles around the web.
Mobile Web Apps Live (or DIE) by the UI
Top 5 Best Practices
          When working with HTML5
1) Use client side DBs instead of server round trips 
2) Use CSS transitions instead of JavaScript animations
(Enable hardware acceleration)
3) Boost performance with JavaScript 1.6 (no more "for
loops")
4) Use cache manifests for live sites, not just offline apps
5) HTML5 Form attributes and input styles (paceholder,
pattern, etc...)
Device & Feature Detection
Device & Feature Detection


 • MobileESP (server-side)
 • Modernizr (client-side)
 • CSS3 Media Queries
Device Detection


• Parsing the USER_AGENT
• WURFL APIs
WURFL
               Wireless Universal Resource File




• Up to date list of all mobile devices
• Available as XML file
• Wrappers for most languages
Feature Detection
 Modernizr
• <html class="js canvas canvastext
  no-geolocation rgba hsla
  multiplebgs borderimage
  borderradius boxshadow opacity
  cssanimations csscolumns
  cssgradients cssreflections
  csstransforms csstransforms3d
  csstransitions video audio
  localstorage sessionstorage
  webworkers applicationcache
  fontface">
Feature Detection
  Modernizr
• Adds classnames of available
  features to DOM

• Allows use of browser features with
  fallback options

• shiv & polyfills
Feature Detection
“Cascading” the detection:
#nice {
    background: url(background-one.png) top left repeat-x;
    background: url(background-one.png) top left repeat-x,
    url(background-two.png) bottom left repeat-x;
}

Using Modernizr:

#nice {
    background: url(background-one.png) top left repeat-x;
}
.multiplebgs #nice {
    background: url(background-one.png) top left repeat-x,
    url(background-two.png) bottom left repeat-x;
}
The Mobile Web
Mobile Platforms




Mobile Frameworks




 And many more...
Todays Focus
Mobile                   Basics

• Hardware Acceleration
• Page Transitions: Sliding, Flipping, and Rotating
• Fetching and Caching
• Network Detection
• Debugging & Profiling
Hardware Acceleration

• Page Layout
• Memory allocation (Compositing)
• Power Consumption
• Conflicts
Hardware Acceleration
         Demo
Hardware Acceleration
    Understanding Page Layout
Hardware Acceleration
    Understanding Page Layout
Hardware Acceleration
      Sliding and Staging
Hardware Acceleration
      Based on device
Hardware Acceleration
                 Compositing Visuals



• Safari Command Line Flags
• Chrome about:flags
Hardware Acceleration
                     Compositing Visuals

• Safari/WebKit Command Line Flags
$> export CA_COLOR_OPAQUE=1
$> export CA_LOG_MEMORY_USAGE=1
$> /Applications/Safari.app/Contents/MacOS/Safari
Hardware Acceleration
Compositing Visuals - WebKit CoreAnimation
Hardware Acceleration
                Compositing Visuals

• Chrome about:flags
Hardware Acceleration
                      Keep In Mind


• Don’t composite every DOM element
• When you make use of the GPU, you’re
  also using the battery

• Beware of overlapping acceleration
Fetching and Caching
       Demo
Fetching and Caching


• Pre-fetch content for smooth transitions
• Setup for offline capability
• Concurrent Ajax
Caching
                by device




 appCache     unlimited     10MB

Web Storage     5MB         5MB
Fetching and Caching

Fetching content and parsing the DOM
Fetching and Caching

Fetching content and parsing the DOM
Fetching and Caching
External page parsed via AJAX call:
Fetching and Caching
localStorage used within the AJAX call:
innerHTML()
“If the HTML text contains a <script> tag or its
equivalent, then an evil script will run. ..

                     Douglas Crockford - Javascript The Good Parts
Java only is innerHTML() bad...
 Not Mobile Web Settings

• Causes browser memory leaks
• You don’t get a reference to the element
  you just created

• Problems with some elements setting
  their innerHTML

• And it fails on iOS...
Java Mobile Web Settings
Beware of innerHTML on


• Stops working randomly
• It’s a 4 year old problem in Safari
• there are hacks to workaround
  • setTimeout(‘yuck’)
Java Mobile Web Settings
      The   Solution

 • get the xhr.responseText
 • send it to an automatically generated
   HTML5 sandbox iframe

 • pull from the iframe DOM and use
   document.adoptNode
Java Mobile Web Settings
      The   Solution
function getFrame() {
    var frame = document.getElementById("temp-frame");
    if (!frame) {
        // create frame
        frame = document.createElement("iframe");
        frame.setAttribute("id", "temp-frame");
        frame.setAttribute("name", "temp-frame");
        frame.setAttribute("seamless", "");
        frame.setAttribute("sandbox", "");
        frame.style.display = 'none';
        document.documentElement.appendChild(frame);
    }
    return frame.contentDocument;
}
Java Mobile Web Settings
      The   Solution


 var frame = getFrame();
 frame.write(responseText);
Java Mobile Web Settings
        The   Solution
document.
getElementById(elementId).
appendChild(document.adoptNode
(incomingElements));
Fetching and Caching
                       Recap

• Get all fetchable links on the parent page
• Concurrently get the external pages
• Cache pages with localStorage
• Do not use innerHTML
• Write fetched content into iframe
• Place it into parent using adoptNode()
Network Detection and Handling
            Demo
Network Detection and Handling



 • Offline access through applicationCache
 • Offline/Online events
 • Content fetching based on network speed
applicationCache
             by device




appCache   unlimited     10MB
Offline Access
           appCache Mime Mappings
web.xml
<mime-mapping>
  <extension>appcache</extension>
  <mime-type>text/cache-manifest</mime-type>
</mime-mapping>


Apache config
applicationCache
demo.appcache
applicationCache
Page usage



Updating the cache
Offline & Online events
event listeners
Offline & Online events
appCache error event
Fetching based on network speed
navigator.connection (The Network Information API)
Fetching based on network speed

WIFI (Asynchronous) Request Timeline




Edge (Synchronous) Request Timeline
#atlhtml5




                     Questions?
                         @wesleyhales
Note - All code and demos presented here will be available on October 4, 2011
    www.html5rocks.com/en/mobile/optimization-and-performance.html

Más contenido relacionado

La actualidad más candente

MongoDB and the MEAN Stack
MongoDB and the MEAN StackMongoDB and the MEAN Stack
MongoDB and the MEAN Stack
MongoDB
 

La actualidad más candente (20)

Prioritize your critical css and images to render your site fast velocity ny...
Prioritize your critical css and images to render your site fast  velocity ny...Prioritize your critical css and images to render your site fast  velocity ny...
Prioritize your critical css and images to render your site fast velocity ny...
 
Advanced front end debugging with ms edge and ms tools
Advanced front end debugging with ms edge and ms toolsAdvanced front end debugging with ms edge and ms tools
Advanced front end debugging with ms edge and ms tools
 
Disrupting the application eco system with progressive web applications
Disrupting the application eco system with progressive web applicationsDisrupting the application eco system with progressive web applications
Disrupting the application eco system with progressive web applications
 
Server rendering-talk
Server rendering-talkServer rendering-talk
Server rendering-talk
 
Breaking the Speed Limit: Faster Websites Win
Breaking the Speed Limit: Faster Websites WinBreaking the Speed Limit: Faster Websites Win
Breaking the Speed Limit: Faster Websites Win
 
More efficient, usable web
More efficient, usable webMore efficient, usable web
More efficient, usable web
 
Building Modern Web Apps with MEAN Stack
Building Modern Web Apps with MEAN StackBuilding Modern Web Apps with MEAN Stack
Building Modern Web Apps with MEAN Stack
 
Javascript for Wep Apps
Javascript for Wep AppsJavascript for Wep Apps
Javascript for Wep Apps
 
Vue - the Progressive Framework
Vue  - the Progressive FrameworkVue  - the Progressive Framework
Vue - the Progressive Framework
 
Intro to Vue
Intro to Vue Intro to Vue
Intro to Vue
 
Drupal8 + AngularJS
Drupal8 + AngularJSDrupal8 + AngularJS
Drupal8 + AngularJS
 
Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!Single Page Applications: Your Browser is the OS!
Single Page Applications: Your Browser is the OS!
 
Building Angular Component Libraries
Building Angular Component LibrariesBuilding Angular Component Libraries
Building Angular Component Libraries
 
The MEAN Stack
The MEAN StackThe MEAN Stack
The MEAN Stack
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
MEAN stack
MEAN stackMEAN stack
MEAN stack
 
Using Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the WebUsing Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the Web
 
Get MEAN! Node.js and the MEAN stack
Get MEAN!  Node.js and the MEAN stackGet MEAN!  Node.js and the MEAN stack
Get MEAN! Node.js and the MEAN stack
 
ReactJS - Re-rendering pages in the age of the mutable DOM
ReactJS - Re-rendering pages in the age of the mutable DOMReactJS - Re-rendering pages in the age of the mutable DOM
ReactJS - Re-rendering pages in the age of the mutable DOM
 
MongoDB and the MEAN Stack
MongoDB and the MEAN StackMongoDB and the MEAN Stack
MongoDB and the MEAN Stack
 

Similar a The Mobile Web - HTML5 on mobile devices

Krug Fat Client
Krug Fat ClientKrug Fat Client
Krug Fat Client
Paul Klipp
 
Webdev battacherjee
Webdev battacherjeeWebdev battacherjee
Webdev battacherjee
RavingTiger
 
Mobile App Development
Mobile App DevelopmentMobile App Development
Mobile App Development
Chris Morrell
 
Web app and more
Web app and moreWeb app and more
Web app and more
faming su
 

Similar a The Mobile Web - HTML5 on mobile devices (20)

HTML5: An Overview
HTML5: An OverviewHTML5: An Overview
HTML5: An Overview
 
Mobile Web
Mobile WebMobile Web
Mobile Web
 
Developer Pitfalls & Strategies for Improving Mobile Web Developer Experience
Developer Pitfalls & Strategies for Improving Mobile Web Developer ExperienceDeveloper Pitfalls & Strategies for Improving Mobile Web Developer Experience
Developer Pitfalls & Strategies for Improving Mobile Web Developer Experience
 
Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011
 
Krug Fat Client
Krug Fat ClientKrug Fat Client
Krug Fat Client
 
Top 10 HTML5 Features for Oracle Cloud Developers
Top 10 HTML5 Features for Oracle Cloud DevelopersTop 10 HTML5 Features for Oracle Cloud Developers
Top 10 HTML5 Features for Oracle Cloud Developers
 
Html5 Application Security
Html5 Application SecurityHtml5 Application Security
Html5 Application Security
 
Women Who Code, Ground Floor
Women Who Code, Ground FloorWomen Who Code, Ground Floor
Women Who Code, Ground Floor
 
performance.ppt
performance.pptperformance.ppt
performance.ppt
 
Webdev battacherjee
Webdev battacherjeeWebdev battacherjee
Webdev battacherjee
 
Android lessons you won't learn in school
Android lessons you won't learn in schoolAndroid lessons you won't learn in school
Android lessons you won't learn in school
 
Mobile App Development
Mobile App DevelopmentMobile App Development
Mobile App Development
 
Making HTML5 Mobile Games Indistinguishable from Native Apps
Making HTML5 Mobile Games Indistinguishable from Native AppsMaking HTML5 Mobile Games Indistinguishable from Native Apps
Making HTML5 Mobile Games Indistinguishable from Native Apps
 
Html5
Html5Html5
Html5
 
Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
 
Web app and more
Web app and moreWeb app and more
Web app and more
 
Developing High Performance Web Apps
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web Apps
 
20120306 dublin js
20120306 dublin js20120306 dublin js
20120306 dublin js
 
Building Mobile Web Apps with jQM and Cordova on Azure
Building Mobile Web Apps with jQM and Cordova on AzureBuilding Mobile Web Apps with jQM and Cordova on Azure
Building Mobile Web Apps with jQM and Cordova on Azure
 

Más de Wesley Hales (6)

Making Portals Cool: The Compelling Advantages of a Portlet Bridge
Making Portals Cool: The Compelling Advantages of a Portlet BridgeMaking Portals Cool: The Compelling Advantages of a Portlet Bridge
Making Portals Cool: The Compelling Advantages of a Portlet Bridge
 
Filling The Gap - Going Mobile With JBoss Technologies Today
Filling The Gap - Going Mobile With JBoss Technologies TodayFilling The Gap - Going Mobile With JBoss Technologies Today
Filling The Gap - Going Mobile With JBoss Technologies Today
 
If You Know JSF, You Know Portals and Portlets
If You Know JSF, You Know Portals and PortletsIf You Know JSF, You Know Portals and Portlets
If You Know JSF, You Know Portals and Portlets
 
GateIn - The Solution for Managing and Building Enterprise Web Apps
GateIn - The Solution for Managing and Building Enterprise Web AppsGateIn - The Solution for Managing and Building Enterprise Web Apps
GateIn - The Solution for Managing and Building Enterprise Web Apps
 
GateIn - Presented at Atlanta JUG on 1/19/2010
GateIn - Presented at Atlanta JUG on 1/19/2010GateIn - Presented at Atlanta JUG on 1/19/2010
GateIn - Presented at Atlanta JUG on 1/19/2010
 
Ajax In Enterprise Portals
Ajax In Enterprise PortalsAjax In Enterprise Portals
Ajax In Enterprise Portals
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

The Mobile Web - HTML5 on mobile devices

  • 1. The Mobile Web - HTML5 on mobile devices HTML5 User Group - Atlanta By: Wesley Hales @wesleyhales
  • 2. Wesley Hales • Senior Developer at Red Hat @w esle • W3C Member yha les • JSR 301/329 Rep. • HTML5 User Group Founder • html5rocks.com, DZone Refcard, and author of many other articles around the web.
  • 3. Mobile Web Apps Live (or DIE) by the UI
  • 4.
  • 5. Top 5 Best Practices When working with HTML5 1) Use client side DBs instead of server round trips  2) Use CSS transitions instead of JavaScript animations (Enable hardware acceleration) 3) Boost performance with JavaScript 1.6 (no more "for loops") 4) Use cache manifests for live sites, not just offline apps 5) HTML5 Form attributes and input styles (paceholder, pattern, etc...)
  • 6. Device & Feature Detection
  • 7. Device & Feature Detection • MobileESP (server-side) • Modernizr (client-side) • CSS3 Media Queries
  • 8. Device Detection • Parsing the USER_AGENT • WURFL APIs
  • 9. WURFL Wireless Universal Resource File • Up to date list of all mobile devices • Available as XML file • Wrappers for most languages
  • 10. Feature Detection Modernizr • <html class="js canvas canvastext no-geolocation rgba hsla multiplebgs borderimage borderradius boxshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions video audio localstorage sessionstorage webworkers applicationcache fontface">
  • 11. Feature Detection Modernizr • Adds classnames of available features to DOM • Allows use of browser features with fallback options • shiv & polyfills
  • 12. Feature Detection “Cascading” the detection: #nice {     background: url(background-one.png) top left repeat-x;     background: url(background-one.png) top left repeat-x,     url(background-two.png) bottom left repeat-x; } Using Modernizr: #nice {     background: url(background-one.png) top left repeat-x; } .multiplebgs #nice {     background: url(background-one.png) top left repeat-x,     url(background-two.png) bottom left repeat-x; }
  • 16. Mobile Basics • Hardware Acceleration • Page Transitions: Sliding, Flipping, and Rotating • Fetching and Caching • Network Detection • Debugging & Profiling
  • 17. Hardware Acceleration • Page Layout • Memory allocation (Compositing) • Power Consumption • Conflicts
  • 19. Hardware Acceleration Understanding Page Layout
  • 20. Hardware Acceleration Understanding Page Layout
  • 21. Hardware Acceleration Sliding and Staging
  • 22. Hardware Acceleration Based on device
  • 23. Hardware Acceleration Compositing Visuals • Safari Command Line Flags • Chrome about:flags
  • 24. Hardware Acceleration Compositing Visuals • Safari/WebKit Command Line Flags $> export CA_COLOR_OPAQUE=1 $> export CA_LOG_MEMORY_USAGE=1 $> /Applications/Safari.app/Contents/MacOS/Safari
  • 26. Hardware Acceleration Compositing Visuals • Chrome about:flags
  • 27. Hardware Acceleration Keep In Mind • Don’t composite every DOM element • When you make use of the GPU, you’re also using the battery • Beware of overlapping acceleration
  • 29. Fetching and Caching • Pre-fetch content for smooth transitions • Setup for offline capability • Concurrent Ajax
  • 30. Caching by device appCache unlimited 10MB Web Storage 5MB 5MB
  • 31. Fetching and Caching Fetching content and parsing the DOM
  • 32. Fetching and Caching Fetching content and parsing the DOM
  • 33. Fetching and Caching External page parsed via AJAX call:
  • 34. Fetching and Caching localStorage used within the AJAX call:
  • 36. “If the HTML text contains a <script> tag or its equivalent, then an evil script will run. .. Douglas Crockford - Javascript The Good Parts
  • 37. Java only is innerHTML() bad... Not Mobile Web Settings • Causes browser memory leaks • You don’t get a reference to the element you just created • Problems with some elements setting their innerHTML • And it fails on iOS...
  • 38. Java Mobile Web Settings Beware of innerHTML on • Stops working randomly • It’s a 4 year old problem in Safari • there are hacks to workaround • setTimeout(‘yuck’)
  • 39. Java Mobile Web Settings The Solution • get the xhr.responseText • send it to an automatically generated HTML5 sandbox iframe • pull from the iframe DOM and use document.adoptNode
  • 40. Java Mobile Web Settings The Solution function getFrame() {     var frame = document.getElementById("temp-frame");     if (!frame) {         // create frame         frame = document.createElement("iframe");         frame.setAttribute("id", "temp-frame");         frame.setAttribute("name", "temp-frame");         frame.setAttribute("seamless", "");         frame.setAttribute("sandbox", "");         frame.style.display = 'none';         document.documentElement.appendChild(frame);     }     return frame.contentDocument; }
  • 41. Java Mobile Web Settings The Solution var frame = getFrame(); frame.write(responseText);
  • 42. Java Mobile Web Settings The Solution document. getElementById(elementId). appendChild(document.adoptNode (incomingElements));
  • 43. Fetching and Caching Recap • Get all fetchable links on the parent page • Concurrently get the external pages • Cache pages with localStorage • Do not use innerHTML • Write fetched content into iframe • Place it into parent using adoptNode()
  • 44. Network Detection and Handling Demo
  • 45. Network Detection and Handling • Offline access through applicationCache • Offline/Online events • Content fetching based on network speed
  • 46. applicationCache by device appCache unlimited 10MB
  • 47. Offline Access appCache Mime Mappings web.xml <mime-mapping> <extension>appcache</extension> <mime-type>text/cache-manifest</mime-type> </mime-mapping> Apache config
  • 50. Offline & Online events event listeners
  • 51. Offline & Online events appCache error event
  • 52. Fetching based on network speed navigator.connection (The Network Information API)
  • 53. Fetching based on network speed WIFI (Asynchronous) Request Timeline Edge (Synchronous) Request Timeline
  • 54. #atlhtml5 Questions? @wesleyhales Note - All code and demos presented here will be available on October 4, 2011 www.html5rocks.com/en/mobile/optimization-and-performance.html