SlideShare una empresa de Scribd logo
1 de 130
Descargar para leer sin conexión
That's Web? Extreme
Optimization for the
    Mobile Web
 Glan Thomas - Disney Interactive
   HTML5 Developer Conference 2012
          San Francisco, CA
About me
... and why I am interested in this stuff
What is a Mobile Web
        App?
Browser based
Webview
What’s it like going
from the desktop to
    mobile web?
Why am interested in
       this


                   © Universal Pictures
What are we trying to
     optimize?
Guest Experience
        http://www.flickr.com/photos/stuckincustoms/518435043/
The	 5	 Great	 Mobile	 
Development	 Challenges
➊ Limited
CPU and
memory
resources
➋ Variety of
Display Densities
➌ High
Network
Latency




          http://www.qsl.net/ylradio/archives/YLstor/images/radioroom.jpg
➍  Matching
Users’ Expectations

             © DreamWorks Pictures / 20th Century Fox
➎ Harder
to Debug




http://www.flickr.com/photos/youraccount/3939769126/
➎   Dealing with
     your VP’s
    pessimism




           © 2010 Columbia TriStar
What if we don’t do
anything?

            ✘ Long load times
            ✘ Partial content
              appearing
            ✘ Unresponsive UI
            ✘ Jittery animations
But It gets worse...
              • Unnecessary data usage
              • Decreased battery life
http://www.flickr.com/photos/flydime/4670141424/
“Q, your app
             sucks.
   I used it for 30
    minutes and it
       drained my
    battery so low
 that I missed my
appointment with
      Dr Crusher!”
                      © CBS Paramount Television / Paramount Pictures
๏ MANY + LARGE HTTP REQUESTS
    = MORE DATA
    = MORE POWER USAGE
    = HIGH BATTERY DRAIN
๏ UNNECESSARY ANIMATIONS
    = HIGH USE OF CPU AND MEMORY
    = MORE POWER USAGE
    = HIGH BATTERY DRAIN
PRIME
DIRECTIVE
"Be green and
 respect the
   battery"




  © CBS Paramount Television / Paramount Pictures
WWW 2012 – Session: Mobile Web Performance                                                            April 16–20, 2012, Lyon, France




                        Who Killed My Battery:
             Analyzing Mobile Browser Energy Consumption

            Narendran Thiagarajan†      Gaurav Aggarwal†           Angela Nicoara*
            naren@cs.stanford.edu agaurav@cs.stanford.edu angela.nicoara@telekom.com
                             Dan Boneh†        Jatinder Pal Singh‡
                       dabo@cs.stanford.edu jatinder@stanford.edu
                                  †
                                   Department of Computer Science, Stanford University, CA
                                  *
                                   Deutsche Telekom R&D Laboratories USA, Los Altos, CA
                                ‡
                                  Department of Electrical Engineering, Stanford University, CA

ABSTRACT                                                               sites are poorly optimized for energy use and rendering them in the
Despite the growing popularity of mobile web browsing, the energy      browser takes more power than necessary. Partly this is due to a
consumed by a phone browser while surfing the web is poorly un-         weak understanding of the browser’s energy use.
derstood. We present an infrastructure for measuring the precise          In this paper we set out to analyze the energy consumption of
energy used by a mobile browser to render web pages. We then           the Android browser at popular web sites such as Facebook, Ama-
measure the energy needed to render financial, e-commerce, email,       zon, and many others. Our experimental setup includes a multi-
blogging, news and social networking sites. Our tools are suffi-        meter hooked up to the phone battery that measures the phone’s
ciently precise to measure the energy needed to render individual      energy consumption as the phone loads and renders web pages. We
web elements, such as cascade style sheets (CSS), Javascript, im-      patched the default Android browser to help us measure the precise
ages, and plug-in objects. Our results show that for popular sites,    energy used from the moment the browser begins navigating to the
downloading and parsing cascade style sheets and Javascript con-       desired web site until the page is fully rendered. The patch also lets
sumes a significant fraction of the total energy needed to render the   us measure the exact energy needed to render a page excluding the
page. Using the data we collected we make concrete recommen-           energy consumed by the radio. Our setup is described in detail in
dations on how to design web pages so as to minimize the energy        Section 2. In that section we also describe the energy model for the
needed to render the page. As an example, by modifying scripts on      phone’s radio which is similar to models presented in [18, 10].
the Wikipedia mobile site we reduced by 30% the energy needed to          Using our experimental setup we measured the energy needed
download and render Wikipedia pages with no change to the user         to render popular web sites as well as the energy needed to render
experience. We conclude by estimating the point at which offload-       individual web elements such as images, Javascript, and Cascade
ing browser computations to a remote proxy can save energy on the      Style Sheets (CSS). We find that complex Javascript and CSS can
                                                                       be as expensive to render as images. Moreover, dynamic Javascript
Crunch Points

            Loading                        User Interaction


Network   Parsing     Execution   Rendering Animation   Events
5 Tips
for optimization
Tip
Don’t take the network for granted
Network
          • High latency.
          • Bandwidth costs money
             (for all parties).
          • Might not be there.
          • It will definitely drain
             the battery.



http://www.flickr.com/photos/robert-dolan/3864148280/
How do you
solve a
problem like
the network?

   Do everything Steve
   Souders tells you to.
• Enable Gzip.
• Reduce number of
  requests.

• Reduce size of
  responses.

• Expires Headers / Etags
• Use a CDN.
• Deliver device specific
  content.

• Don’t use the network
  unless we absolutely
  positively need to.
Images
• Optimization tools (ImageOptim,
  ImageAlpha).
• Sprites to reduce requests.
• Device specific images.
• Base64 inline (pros & cons).
• CSS and Unicode Glyphs to replace images.
• CSS image masks for alpha.
Original PNG       JPEG      3bit PNG Mask
    33Kb           19Kb           4.7Kb
               --- 23.7Kb ~ 29% saving ---
Tip
If you really must make the user wait,
            show something.
Ideal App Usage Cycle
•   Load App (HTML & CSS)

•   Render

•   Load Source (JS)

•   Parse

•   Execute

•   Parallel Operations

    •   User Events

    •   Deferred Loads (data and images)
Tip
Use HTML5 and other goodies
HTML5
• LocalStorage
• AppCache
• Network / Connection API
• Battery API
• Web workers and shared web workers
• Things we don’t need libraries for:
 • JSON, QuerySelector, ClassLists
JavaScript Libraries

• Modular
• Lightweight
• Maintained
• Understandable
Tip
Don't animate anything that you can't reliably
            offload to the GPU
The GPU
• translate3d, scale3d, rotate3d
• Beware of the 1024px texture size limit
• Interaction between the CPU and GPU
• Don’t load too much on to it (~10Mb total
  storage)
Rendering and Updates

• Avoid reflows
• Carefully use opacity/transparency fades.
• requestAnimationFrame
Tip
Keep the DOM simple and use event
         listeners carefully
Putting things together
Build
process

 • Build process
 • Testing and
   debugging



               http://floridakeysgirl.com/wp-content/uploads/2010/10/IMG_1147-e1288555102991.jpg
Debugging and Testing
•   Desktop Webkit

•   Simulator / Emulators

•   weinre - WEb INspector REmote

•   Charles proxy

•   Mobile Perf Bookmarklet (YSlow, DOM
    Monster)

•   PhantomJS, Selenium
•   Real devices, with real OSs
Recap
•   Prime Directive: Respect the battery.

•   #1 Don’t rely too much on the network.

•   #2 Show something while loading.

•   #3 Use HTML5 extensions.

•   #4 Use hardware acceleration.

•   #5 Keep the DOM simple. Use event listeners
    carefully and appropriately.
Thanks for all the fish




                          @glan
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web
Extreme Optimization for the Mobile Web

Más contenido relacionado

La actualidad más candente

Progressive Web App Challenges
Progressive Web App ChallengesProgressive Web App Challenges
Progressive Web App ChallengesJason Grigsby
 
Delivering Optimal Images for Phones and Tablets on the Modern Web
Delivering Optimal Images for Phones and Tablets on the Modern WebDelivering Optimal Images for Phones and Tablets on the Modern Web
Delivering Optimal Images for Phones and Tablets on the Modern WebJoshua Marantz
 
Speed is Essential for a Great Web Experience
Speed is Essential for a Great Web ExperienceSpeed is Essential for a Great Web Experience
Speed is Essential for a Great Web ExperienceAndy Davies
 
Performance as UX with Justin Howlett
Performance as UX with Justin HowlettPerformance as UX with Justin Howlett
Performance as UX with Justin HowlettFITC
 
OSCAL: Free and Open Source Tools for Image and Video Performance
OSCAL: Free and Open Source Tools for Image and Video PerformanceOSCAL: Free and Open Source Tools for Image and Video Performance
OSCAL: Free and Open Source Tools for Image and Video PerformanceDoug Sillars
 
Raiders of the Fast Start: Frontend Performance Archaeology - Performance.now...
Raiders of the Fast Start: Frontend Performance Archaeology - Performance.now...Raiders of the Fast Start: Frontend Performance Archaeology - Performance.now...
Raiders of the Fast Start: Frontend Performance Archaeology - Performance.now...Katie Sylor-Miller
 
Responsive Images and Performance
Responsive Images and PerformanceResponsive Images and Performance
Responsive Images and PerformanceMaximiliano Firtman
 
High Performance Web - Full Stack Toronto
High Performance Web - Full Stack TorontoHigh Performance Web - Full Stack Toronto
High Performance Web - Full Stack TorontoMaximiliano Firtman
 
Performance.now() fast but not furious
Performance.now()   fast but not furiousPerformance.now()   fast but not furious
Performance.now() fast but not furiousAnna Migas
 
Optimizing for a faster user experience Pt 2: How-to.
Optimizing for a faster user experience Pt 2: How-to.Optimizing for a faster user experience Pt 2: How-to.
Optimizing for a faster user experience Pt 2: How-to.James Christie
 
Imagesandvideo tallinn
Imagesandvideo tallinnImagesandvideo tallinn
Imagesandvideo tallinnDoug Sillars
 
AWS Webcast - Accelerating Application Performance Using In-Memory Caching in...
AWS Webcast - Accelerating Application Performance Using In-Memory Caching in...AWS Webcast - Accelerating Application Performance Using In-Memory Caching in...
AWS Webcast - Accelerating Application Performance Using In-Memory Caching in...Amazon Web Services
 
Planning Your Progressive Web App
Planning Your Progressive Web AppPlanning Your Progressive Web App
Planning Your Progressive Web AppJason Grigsby
 
Edi react fastandbeautiful
Edi react fastandbeautifulEdi react fastandbeautiful
Edi react fastandbeautifulDoug Sillars
 
Measuring Web Performance (HighEdWeb FL Edition)
Measuring Web Performance (HighEdWeb FL Edition)Measuring Web Performance (HighEdWeb FL Edition)
Measuring Web Performance (HighEdWeb FL Edition)Dave Olsen
 
2017 Silicon Valley Code Camp: Instant Mobile Web
2017 Silicon Valley Code Camp: Instant Mobile Web2017 Silicon Valley Code Camp: Instant Mobile Web
2017 Silicon Valley Code Camp: Instant Mobile WebLisa Huang
 
Mot cph when its just too slow
Mot cph when its just too slowMot cph when its just too slow
Mot cph when its just too slowDoug Sillars
 
Mobile Web Speed Bumps
Mobile Web Speed BumpsMobile Web Speed Bumps
Mobile Web Speed BumpsNicholas Zakas
 

La actualidad más candente (18)

Progressive Web App Challenges
Progressive Web App ChallengesProgressive Web App Challenges
Progressive Web App Challenges
 
Delivering Optimal Images for Phones and Tablets on the Modern Web
Delivering Optimal Images for Phones and Tablets on the Modern WebDelivering Optimal Images for Phones and Tablets on the Modern Web
Delivering Optimal Images for Phones and Tablets on the Modern Web
 
Speed is Essential for a Great Web Experience
Speed is Essential for a Great Web ExperienceSpeed is Essential for a Great Web Experience
Speed is Essential for a Great Web Experience
 
Performance as UX with Justin Howlett
Performance as UX with Justin HowlettPerformance as UX with Justin Howlett
Performance as UX with Justin Howlett
 
OSCAL: Free and Open Source Tools for Image and Video Performance
OSCAL: Free and Open Source Tools for Image and Video PerformanceOSCAL: Free and Open Source Tools for Image and Video Performance
OSCAL: Free and Open Source Tools for Image and Video Performance
 
Raiders of the Fast Start: Frontend Performance Archaeology - Performance.now...
Raiders of the Fast Start: Frontend Performance Archaeology - Performance.now...Raiders of the Fast Start: Frontend Performance Archaeology - Performance.now...
Raiders of the Fast Start: Frontend Performance Archaeology - Performance.now...
 
Responsive Images and Performance
Responsive Images and PerformanceResponsive Images and Performance
Responsive Images and Performance
 
High Performance Web - Full Stack Toronto
High Performance Web - Full Stack TorontoHigh Performance Web - Full Stack Toronto
High Performance Web - Full Stack Toronto
 
Performance.now() fast but not furious
Performance.now()   fast but not furiousPerformance.now()   fast but not furious
Performance.now() fast but not furious
 
Optimizing for a faster user experience Pt 2: How-to.
Optimizing for a faster user experience Pt 2: How-to.Optimizing for a faster user experience Pt 2: How-to.
Optimizing for a faster user experience Pt 2: How-to.
 
Imagesandvideo tallinn
Imagesandvideo tallinnImagesandvideo tallinn
Imagesandvideo tallinn
 
AWS Webcast - Accelerating Application Performance Using In-Memory Caching in...
AWS Webcast - Accelerating Application Performance Using In-Memory Caching in...AWS Webcast - Accelerating Application Performance Using In-Memory Caching in...
AWS Webcast - Accelerating Application Performance Using In-Memory Caching in...
 
Planning Your Progressive Web App
Planning Your Progressive Web AppPlanning Your Progressive Web App
Planning Your Progressive Web App
 
Edi react fastandbeautiful
Edi react fastandbeautifulEdi react fastandbeautiful
Edi react fastandbeautiful
 
Measuring Web Performance (HighEdWeb FL Edition)
Measuring Web Performance (HighEdWeb FL Edition)Measuring Web Performance (HighEdWeb FL Edition)
Measuring Web Performance (HighEdWeb FL Edition)
 
2017 Silicon Valley Code Camp: Instant Mobile Web
2017 Silicon Valley Code Camp: Instant Mobile Web2017 Silicon Valley Code Camp: Instant Mobile Web
2017 Silicon Valley Code Camp: Instant Mobile Web
 
Mot cph when its just too slow
Mot cph when its just too slowMot cph when its just too slow
Mot cph when its just too slow
 
Mobile Web Speed Bumps
Mobile Web Speed BumpsMobile Web Speed Bumps
Mobile Web Speed Bumps
 

Similar a Extreme Optimization for the Mobile Web

Delivering Mobile Apps That Perform
Delivering Mobile Apps That PerformDelivering Mobile Apps That Perform
Delivering Mobile Apps That PerformRuben Goncalves
 
Mobile is slow - Over the Air 2013
Mobile is slow - Over the Air 2013Mobile is slow - Over the Air 2013
Mobile is slow - Over the Air 2013Jon Arne Sæterås
 
Everything You Know is Not Quite Right Anymore: Rethinking Best Web Practices...
Everything You Know is Not Quite Right Anymore: Rethinking Best Web Practices...Everything You Know is Not Quite Right Anymore: Rethinking Best Web Practices...
Everything You Know is Not Quite Right Anymore: Rethinking Best Web Practices...Doug Gapinski
 
Everything You Know is Not Quite Right Anymore: Rethinking Best Practices to ...
Everything You Know is Not Quite Right Anymore: Rethinking Best Practices to ...Everything You Know is Not Quite Right Anymore: Rethinking Best Practices to ...
Everything You Know is Not Quite Right Anymore: Rethinking Best Practices to ...Dave Olsen
 
The Server Side of Responsive Web Design
The Server Side of Responsive Web DesignThe Server Side of Responsive Web Design
The Server Side of Responsive Web DesignDave Olsen
 
Monkeytalk Fall 2012 - Responsive Web Design
Monkeytalk Fall 2012 - Responsive Web DesignMonkeytalk Fall 2012 - Responsive Web Design
Monkeytalk Fall 2012 - Responsive Web DesignSerge Hufkens
 
Doug Sillars on App Optimization
Doug Sillars on App OptimizationDoug Sillars on App Optimization
Doug Sillars on App Optimizationwipjam
 
NU Web Steering Committee - Oct 11 - Web Performance
NU Web Steering Committee - Oct 11 - Web PerformanceNU Web Steering Committee - Oct 11 - Web Performance
NU Web Steering Committee - Oct 11 - Web PerformanceLee Roberson
 
Building Highly Optimized Mobile Web Apps
Building Highly Optimized Mobile Web AppsBuilding Highly Optimized Mobile Web Apps
Building Highly Optimized Mobile Web AppsGlan Thomas
 
Is your mobile app up to speed softwaresymposium
Is your mobile app up to speed softwaresymposiumIs your mobile app up to speed softwaresymposium
Is your mobile app up to speed softwaresymposiumDoug Sillars
 
Optimizing browser experience - App!mobile 2013 conf
Optimizing browser experience - App!mobile 2013 confOptimizing browser experience - App!mobile 2013 conf
Optimizing browser experience - App!mobile 2013 confMáté Nádasdi
 
The Dark Side of Single Page Applications
The Dark Side of Single Page ApplicationsThe Dark Side of Single Page Applications
The Dark Side of Single Page ApplicationsDor Kalev
 
Talk 03 responsive-web-design
Talk 03 responsive-web-designTalk 03 responsive-web-design
Talk 03 responsive-web-designMonkeyshot
 
20 tips for website performance
20 tips for website performance20 tips for website performance
20 tips for website performanceAndrew Siemer
 
Performance Optimization for Mobile Web | Fresh Tilled Soil
Performance Optimization for Mobile Web | Fresh Tilled SoilPerformance Optimization for Mobile Web | Fresh Tilled Soil
Performance Optimization for Mobile Web | Fresh Tilled SoilFresh Tilled Soil
 
Practical Thin Server Architecture With Dojo Sapo Codebits 2008
Practical Thin Server Architecture With Dojo Sapo Codebits 2008Practical Thin Server Architecture With Dojo Sapo Codebits 2008
Practical Thin Server Architecture With Dojo Sapo Codebits 2008codebits
 

Similar a Extreme Optimization for the Mobile Web (20)

Delivering Mobile Apps That Perform
Delivering Mobile Apps That PerformDelivering Mobile Apps That Perform
Delivering Mobile Apps That Perform
 
Mobile is slow - Over the Air 2013
Mobile is slow - Over the Air 2013Mobile is slow - Over the Air 2013
Mobile is slow - Over the Air 2013
 
Everything You Know is Not Quite Right Anymore: Rethinking Best Web Practices...
Everything You Know is Not Quite Right Anymore: Rethinking Best Web Practices...Everything You Know is Not Quite Right Anymore: Rethinking Best Web Practices...
Everything You Know is Not Quite Right Anymore: Rethinking Best Web Practices...
 
Everything You Know is Not Quite Right Anymore: Rethinking Best Practices to ...
Everything You Know is Not Quite Right Anymore: Rethinking Best Practices to ...Everything You Know is Not Quite Right Anymore: Rethinking Best Practices to ...
Everything You Know is Not Quite Right Anymore: Rethinking Best Practices to ...
 
Mobile web performance dwx13
Mobile web performance dwx13Mobile web performance dwx13
Mobile web performance dwx13
 
The Server Side of Responsive Web Design
The Server Side of Responsive Web DesignThe Server Side of Responsive Web Design
The Server Side of Responsive Web Design
 
Monkeytalk Fall 2012 - Responsive Web Design
Monkeytalk Fall 2012 - Responsive Web DesignMonkeytalk Fall 2012 - Responsive Web Design
Monkeytalk Fall 2012 - Responsive Web Design
 
Modern Web Applications
Modern Web ApplicationsModern Web Applications
Modern Web Applications
 
Doug Sillars on App Optimization
Doug Sillars on App OptimizationDoug Sillars on App Optimization
Doug Sillars on App Optimization
 
NU Web Steering Committee - Oct 11 - Web Performance
NU Web Steering Committee - Oct 11 - Web PerformanceNU Web Steering Committee - Oct 11 - Web Performance
NU Web Steering Committee - Oct 11 - Web Performance
 
Building Highly Optimized Mobile Web Apps
Building Highly Optimized Mobile Web AppsBuilding Highly Optimized Mobile Web Apps
Building Highly Optimized Mobile Web Apps
 
Is your mobile app up to speed softwaresymposium
Is your mobile app up to speed softwaresymposiumIs your mobile app up to speed softwaresymposium
Is your mobile app up to speed softwaresymposium
 
Web Leaps Forward
Web Leaps ForwardWeb Leaps Forward
Web Leaps Forward
 
Optimizing browser experience - App!mobile 2013 conf
Optimizing browser experience - App!mobile 2013 confOptimizing browser experience - App!mobile 2013 conf
Optimizing browser experience - App!mobile 2013 conf
 
The Dark Side of Single Page Applications
The Dark Side of Single Page ApplicationsThe Dark Side of Single Page Applications
The Dark Side of Single Page Applications
 
Talk 03 responsive-web-design
Talk 03 responsive-web-designTalk 03 responsive-web-design
Talk 03 responsive-web-design
 
Web Performance Optimization
Web Performance OptimizationWeb Performance Optimization
Web Performance Optimization
 
20 tips for website performance
20 tips for website performance20 tips for website performance
20 tips for website performance
 
Performance Optimization for Mobile Web | Fresh Tilled Soil
Performance Optimization for Mobile Web | Fresh Tilled SoilPerformance Optimization for Mobile Web | Fresh Tilled Soil
Performance Optimization for Mobile Web | Fresh Tilled Soil
 
Practical Thin Server Architecture With Dojo Sapo Codebits 2008
Practical Thin Server Architecture With Dojo Sapo Codebits 2008Practical Thin Server Architecture With Dojo Sapo Codebits 2008
Practical Thin Server Architecture With Dojo Sapo Codebits 2008
 

Último

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Último (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

Extreme Optimization for the Mobile Web

  • 1. That's Web? Extreme Optimization for the Mobile Web Glan Thomas - Disney Interactive HTML5 Developer Conference 2012 San Francisco, CA
  • 2. About me ... and why I am interested in this stuff
  • 3. What is a Mobile Web App?
  • 6. What’s it like going from the desktop to mobile web?
  • 7. Why am interested in this © Universal Pictures
  • 8. What are we trying to optimize?
  • 9. Guest Experience http://www.flickr.com/photos/stuckincustoms/518435043/
  • 10. The 5 Great Mobile Development Challenges
  • 13. ➌ High Network Latency http://www.qsl.net/ylradio/archives/YLstor/images/radioroom.jpg
  • 14. ➍ Matching Users’ Expectations © DreamWorks Pictures / 20th Century Fox
  • 16. Dealing with your VP’s pessimism © 2010 Columbia TriStar
  • 17. What if we don’t do anything? ✘ Long load times ✘ Partial content appearing ✘ Unresponsive UI ✘ Jittery animations
  • 18. But It gets worse... • Unnecessary data usage • Decreased battery life http://www.flickr.com/photos/flydime/4670141424/
  • 19. “Q, your app sucks. I used it for 30 minutes and it drained my battery so low that I missed my appointment with Dr Crusher!” © CBS Paramount Television / Paramount Pictures
  • 20. ๏ MANY + LARGE HTTP REQUESTS = MORE DATA = MORE POWER USAGE = HIGH BATTERY DRAIN ๏ UNNECESSARY ANIMATIONS = HIGH USE OF CPU AND MEMORY = MORE POWER USAGE = HIGH BATTERY DRAIN
  • 21. PRIME DIRECTIVE "Be green and respect the battery" © CBS Paramount Television / Paramount Pictures
  • 22. WWW 2012 – Session: Mobile Web Performance April 16–20, 2012, Lyon, France Who Killed My Battery: Analyzing Mobile Browser Energy Consumption Narendran Thiagarajan† Gaurav Aggarwal† Angela Nicoara* naren@cs.stanford.edu agaurav@cs.stanford.edu angela.nicoara@telekom.com Dan Boneh† Jatinder Pal Singh‡ dabo@cs.stanford.edu jatinder@stanford.edu † Department of Computer Science, Stanford University, CA * Deutsche Telekom R&D Laboratories USA, Los Altos, CA ‡ Department of Electrical Engineering, Stanford University, CA ABSTRACT sites are poorly optimized for energy use and rendering them in the Despite the growing popularity of mobile web browsing, the energy browser takes more power than necessary. Partly this is due to a consumed by a phone browser while surfing the web is poorly un- weak understanding of the browser’s energy use. derstood. We present an infrastructure for measuring the precise In this paper we set out to analyze the energy consumption of energy used by a mobile browser to render web pages. We then the Android browser at popular web sites such as Facebook, Ama- measure the energy needed to render financial, e-commerce, email, zon, and many others. Our experimental setup includes a multi- blogging, news and social networking sites. Our tools are suffi- meter hooked up to the phone battery that measures the phone’s ciently precise to measure the energy needed to render individual energy consumption as the phone loads and renders web pages. We web elements, such as cascade style sheets (CSS), Javascript, im- patched the default Android browser to help us measure the precise ages, and plug-in objects. Our results show that for popular sites, energy used from the moment the browser begins navigating to the downloading and parsing cascade style sheets and Javascript con- desired web site until the page is fully rendered. The patch also lets sumes a significant fraction of the total energy needed to render the us measure the exact energy needed to render a page excluding the page. Using the data we collected we make concrete recommen- energy consumed by the radio. Our setup is described in detail in dations on how to design web pages so as to minimize the energy Section 2. In that section we also describe the energy model for the needed to render the page. As an example, by modifying scripts on phone’s radio which is similar to models presented in [18, 10]. the Wikipedia mobile site we reduced by 30% the energy needed to Using our experimental setup we measured the energy needed download and render Wikipedia pages with no change to the user to render popular web sites as well as the energy needed to render experience. We conclude by estimating the point at which offload- individual web elements such as images, Javascript, and Cascade ing browser computations to a remote proxy can save energy on the Style Sheets (CSS). We find that complex Javascript and CSS can be as expensive to render as images. Moreover, dynamic Javascript
  • 23. Crunch Points Loading User Interaction Network Parsing Execution Rendering Animation Events
  • 25. Tip Don’t take the network for granted
  • 26. Network • High latency. • Bandwidth costs money (for all parties). • Might not be there. • It will definitely drain the battery. http://www.flickr.com/photos/robert-dolan/3864148280/
  • 27. How do you solve a problem like the network? Do everything Steve Souders tells you to.
  • 28. • Enable Gzip. • Reduce number of requests. • Reduce size of responses. • Expires Headers / Etags • Use a CDN. • Deliver device specific content. • Don’t use the network unless we absolutely positively need to.
  • 29. Images • Optimization tools (ImageOptim, ImageAlpha). • Sprites to reduce requests. • Device specific images. • Base64 inline (pros & cons). • CSS and Unicode Glyphs to replace images. • CSS image masks for alpha.
  • 30. Original PNG JPEG 3bit PNG Mask 33Kb 19Kb 4.7Kb --- 23.7Kb ~ 29% saving ---
  • 31. Tip If you really must make the user wait, show something.
  • 32. Ideal App Usage Cycle • Load App (HTML & CSS) • Render • Load Source (JS) • Parse • Execute • Parallel Operations • User Events • Deferred Loads (data and images)
  • 33. Tip Use HTML5 and other goodies
  • 34. HTML5 • LocalStorage • AppCache • Network / Connection API • Battery API • Web workers and shared web workers • Things we don’t need libraries for: • JSON, QuerySelector, ClassLists
  • 35. JavaScript Libraries • Modular • Lightweight • Maintained • Understandable
  • 36. Tip Don't animate anything that you can't reliably offload to the GPU
  • 37. The GPU • translate3d, scale3d, rotate3d • Beware of the 1024px texture size limit • Interaction between the CPU and GPU • Don’t load too much on to it (~10Mb total storage)
  • 38. Rendering and Updates • Avoid reflows • Carefully use opacity/transparency fades. • requestAnimationFrame
  • 39. Tip Keep the DOM simple and use event listeners carefully
  • 41. Build process • Build process • Testing and debugging http://floridakeysgirl.com/wp-content/uploads/2010/10/IMG_1147-e1288555102991.jpg
  • 42. Debugging and Testing • Desktop Webkit • Simulator / Emulators • weinre - WEb INspector REmote • Charles proxy • Mobile Perf Bookmarklet (YSlow, DOM Monster) • PhantomJS, Selenium • Real devices, with real OSs
  • 43. Recap • Prime Directive: Respect the battery. • #1 Don’t rely too much on the network. • #2 Show something while loading. • #3 Use HTML5 extensions. • #4 Use hardware acceleration. • #5 Keep the DOM simple. Use event listeners carefully and appropriately.
  • 44. Thanks for all the fish @glan

Notas del editor

  1. \n
  2. I’m going to start by talking about how I got here and why I’m up here talking about Building awesome mobile web apps.\n\nTraditionally I’m a full-stack web dev\nOver the past few years a I’m chosen my side, said good bye to PHP and MySQL\n and focusing on frontend.\n\nToday I work for Disney Interactive, building HTML5 games, \nBefore this I worked for Tapulous of the successful ‘Tap Tap Revenge’ franchise. \n\n\n
  3. \n
  4. I used to work for these guys. I worked on building websites for a few large broadcasters including the BBC and BSkyB. I also did a fair bit consultancy and freelancing work too.\n
  5. Today work for Tapulous, makers of the successful ‘Tap Tap Revenge’ franchise. Tapulous is also part of Disney Mobile who make games such as ‘Where’s My Water’ and ‘Pirates of the Caribbean’.\nCorporate Inception\n\n
  6. \n
  7. Ok what do we mean by a mobile web app?\n\n1). Could be a standalone web app running in Mobile Safari, Chrome, Firefox, Opera Mobile or Windows Mobile 7 browser. Simply accessed via a URL\n\n2) The web app could be part of Native App and presented with a WebView container. The web app my represent all or just part of the main App.\n\nOur HTML, CSS, JavaScript and other assets may be packaged within the app or delivered via a network.\n\nThese include Ads, news, dynamic content.\n\nExamples include the iTunes store app, iAds.\n
  8. Ok what do we mean by a mobile web app?\n\n1). Could be a standalone web app running in Mobile Safari, Chrome, Firefox, Opera Mobile or Windows Mobile 7 browser. Simply accessed via a URL\n\n2) The web app could be part of Native App and presented with a WebView container. The web app my represent all or just part of the main App.\n\nOur HTML, CSS, JavaScript and other assets may be packaged within the app or delivered via a network.\n\nThese include Ads, news, dynamic content.\n\nExamples include the iTunes store app, iAds.\n
  9. Ok what do we mean by a mobile web app?\n\n1). Could be a standalone web app running in Mobile Safari, Chrome, Firefox, Opera Mobile or Windows Mobile 7 browser. Simply accessed via a URL\n\n2) The web app could be part of Native App and presented with a WebView container. The web app my represent all or just part of the main App.\n\nOur HTML, CSS, JavaScript and other assets may be packaged within the app or delivered via a network.\n\nThese include Ads, news, dynamic content.\n\nExamples include the iTunes store app, iAds.\n
  10. Ok what do we mean by a mobile web app?\n\n1). Could be a standalone web app running in Mobile Safari, Chrome, Firefox, Opera Mobile or Windows Mobile 7 browser. Simply accessed via a URL\n\n2) The web app could be part of Native App and presented with a WebView container. The web app my represent all or just part of the main App.\n\nOur HTML, CSS, JavaScript and other assets may be packaged within the app or delivered via a network.\n\nThese include Ads, news, dynamic content.\n\nExamples include the iTunes store app, iAds.\n
  11. Let me start by defining what I think a mobile web app is.\nCos those last screenshots didn’t look Web, cos they not.\n
  12. Google maps, Twitter, Facebook, LinkedIn\nSingle page load with lots user interaction\n
  13. Native App with webviews.\nNetwork loaded or prepacked\nTap Tap Revenge, Tap Tap Glee, LinkedIn\nApple use web views too for iTunes, iAd and many other apps.\nPhonegap - Great for cross device and app store discovery.\n\n
  14. A lot of this talk is about things problems which I encountered over the past 2 years\nand possible solutions we found. How HTML5 Helps\n
  15. I like to think of the Mobile web as the Wild West, everyone is rushing to stake a claim.\nLots of experimentation\nNew device APIs being built.\nFast paced change.\nCompeting technologies and platforms.\nIn some ways there is also an element of history repeating itself. 90s-2000s\nAlso a battle between Native and Web components.\n\n
  16. I said I was going to talk about this, but what...\n
  17. It’s kind of fitting, since Disney is all-about giving great guest experiences.\n\nThis is what all web app developers want to do. However on mobile we have a few challenges...\n\nI hope the same applies to this talk.\n\nGreat / fast apps make more money\n
  18. \n
  19. The first thing we have to deal with is a user’s exceptions. In the mobile world they are kind of spoilt by native apps and expect a web app to look and feel as responsive. This exception is quite different from the normal web, where users click links and spend time reading. On the mobile, the user is probably going to spend less time reading and more time navigating, so we need to react quicker.\n\nSo we need to over a level of refinement which are as close to a native view as possible, but still have the dynamism of a web view. If we transition from a Native view to a web view we want to avoid avoid a jarring experience. One thing which I’m not intending to talk about is how we can make out web view look like a native App, this is non-trial and in the case of Android there are so many different skins and user experiences that I’m not touching that with a 10 foot pole.\n\nAt the same time as matching a users expectations we need to deal with the mobile network, which ain’t the same a hardline.\n\nOther factors include the limited CPU and Memory resources which are available on a mobile device. Also not all devices are equal, so something which is performant on one device might not be the same on another. \n\nThis kind of leads us on to the next point. With the advent the high density displays such as the Retina display we now have device pixel ratios of 2x, 1.5x and 1x depending on the device.\n
  20. The first thing we have to deal with is a user’s exceptions. In the mobile world they are kind of spoilt by native apps and expect a web app to look and feel as responsive. This exception is quite different from the normal web, where users click links and spend time reading. On the mobile, the user is probably going to spend less time reading and more time navigating, so we need to react quicker.\n\nSo we need to over a level of refinement which are as close to a native view as possible, but still have the dynamism of a web view. If we transition from a Native view to a web view we want to avoid avoid a jarring experience. One thing which I’m not intending to talk about is how we can make out web view look like a native App, this is non-trial and in the case of Android there are so many different skins and user experiences that I’m not touching that with a 10 foot pole.\n\nAt the same time as matching a users expectations we need to deal with the mobile network, which ain’t the same a hardline.\n\nOther factors include the limited CPU and Memory resources which are available on a mobile device. Also not all devices are equal, so something which is performant on one device might not be the same on another. \n\nThis kind of leads us on to the next point. With the advent the high density displays such as the Retina display we now have device pixel ratios of 2x, 1.5x and 1x depending on the device.\n
  21. The first thing we have to deal with is a user’s exceptions. In the mobile world they are kind of spoilt by native apps and expect a web app to look and feel as responsive. This exception is quite different from the normal web, where users click links and spend time reading. On the mobile, the user is probably going to spend less time reading and more time navigating, so we need to react quicker.\n\nSo we need to over a level of refinement which are as close to a native view as possible, but still have the dynamism of a web view. If we transition from a Native view to a web view we want to avoid avoid a jarring experience. One thing which I’m not intending to talk about is how we can make out web view look like a native App, this is non-trial and in the case of Android there are so many different skins and user experiences that I’m not touching that with a 10 foot pole.\n\nAt the same time as matching a users expectations we need to deal with the mobile network, which ain’t the same a hardline.\n\nOther factors include the limited CPU and Memory resources which are available on a mobile device. Also not all devices are equal, so something which is performant on one device might not be the same on another. \n\nThis kind of leads us on to the next point. With the advent the high density displays such as the Retina display we now have device pixel ratios of 2x, 1.5x and 1x depending on the device.\n
  22. The first thing we have to deal with is a user’s exceptions. In the mobile world they are kind of spoilt by native apps and expect a web app to look and feel as responsive. This exception is quite different from the normal web, where users click links and spend time reading. On the mobile, the user is probably going to spend less time reading and more time navigating, so we need to react quicker.\n\nSo we need to over a level of refinement which are as close to a native view as possible, but still have the dynamism of a web view. If we transition from a Native view to a web view we want to avoid avoid a jarring experience. One thing which I’m not intending to talk about is how we can make out web view look like a native App, this is non-trial and in the case of Android there are so many different skins and user experiences that I’m not touching that with a 10 foot pole.\n\nAt the same time as matching a users expectations we need to deal with the mobile network, which ain’t the same a hardline.\n\nOther factors include the limited CPU and Memory resources which are available on a mobile device. Also not all devices are equal, so something which is performant on one device might not be the same on another. \n\nThis kind of leads us on to the next point. With the advent the high density displays such as the Retina display we now have device pixel ratios of 2x, 1.5x and 1x depending on the device.\n
  23. The first thing we have to deal with is a user’s exceptions. In the mobile world they are kind of spoilt by native apps and expect a web app to look and feel as responsive. This exception is quite different from the normal web, where users click links and spend time reading. On the mobile, the user is probably going to spend less time reading and more time navigating, so we need to react quicker.\n\nSo we need to over a level of refinement which are as close to a native view as possible, but still have the dynamism of a web view. If we transition from a Native view to a web view we want to avoid avoid a jarring experience. One thing which I’m not intending to talk about is how we can make out web view look like a native App, this is non-trial and in the case of Android there are so many different skins and user experiences that I’m not touching that with a 10 foot pole.\n\nAt the same time as matching a users expectations we need to deal with the mobile network, which ain’t the same a hardline.\n\nOther factors include the limited CPU and Memory resources which are available on a mobile device. Also not all devices are equal, so something which is performant on one device might not be the same on another. \n\nThis kind of leads us on to the next point. With the advent the high density displays such as the Retina display we now have device pixel ratios of 2x, 1.5x and 1x depending on the device.\n
  24. Mobile devices have processors which are less powerful than desktops.\nLess RAM\nA mobile phone’s spec is closer to a computer 5 years ago.\n
  25. Multiple densities 1x, 1.5x, 2x\n2x => 4 times the pixels which means more data.\nA pixel is not a pixel\n\n
  26. Mobile devices of course often reply on cellular networks.\nThey getting faster. They are still a lot slower than Ethernet or Broadband.\nAlso if we using public WiFI, generally these are also pretty slow too. \n
  27. Finally, Mobile users have become accustomed to Native interfaces, which are responsive \n
  28. Like blackboxes.\nIt’s hard to see how things are running on them.\nWether it is Debugging or Performance optimization.\n\n
  29. Someone said HTML5 didn’t work for them.\nNon technical challenge.\nget rid of preconceptions.\n
  30. All this ==> Crappy user experience\n\nThings that the user will notice right away.\n
  31. All this ==> Crappy user experience\n\nThings that the user will notice right away.\n
  32. All this ==> Crappy user experience\n\nThings that the user will notice right away.\n
  33. All this ==> Crappy user experience\n\nThings that the user will notice right away.\n
  34. All this ==> Crappy user experience\n\nThings that the user will notice right away.\n
  35. All this ==> Crappy user experience\n\nThings that the user will notice right away.\n
  36. Not only that... It gets worse... What might a user notice later...\nLets also think about some side effects\n\nData usage - we don't want to abuse a user's quota.\nBattery life - lets not run a user's device battery down unnecessary.\n\nHere are real world example...\n
  37. Not only that... It gets worse... What might a user notice later...\nLets also think about some side effects\n\nData usage - we don't want to abuse a user's quota.\nBattery life - lets not run a user's device battery down unnecessary.\n\nHere are real world example...\n
  38. Not only that... It gets worse... What might a user notice later...\nLets also think about some side effects\n\nData usage - we don't want to abuse a user's quota.\nBattery life - lets not run a user's device battery down unnecessary.\n\nHere are real world example...\n
  39. \n
  40. Lets look at what might be going on\n\nOh! there is a common theme.\nCause and Effect\n\nOccam's Razor\n\n\n
  41. Lets look at what might be going on\n\nOh! there is a common theme.\nCause and Effect\n\nOccam's Razor\n\n\n
  42. Lets look at what might be going on\n\nOh! there is a common theme.\nCause and Effect\n\nOccam's Razor\n\n\n
  43. Lets look at what might be going on\n\nOh! there is a common theme.\nCause and Effect\n\nOccam's Razor\n\n\n
  44. Lets look at what might be going on\n\nOh! there is a common theme.\nCause and Effect\n\nOccam's Razor\n\n\n
  45. Lets look at what might be going on\n\nOh! there is a common theme.\nCause and Effect\n\nOccam's Razor\n\n\n
  46. Lets look at what might be going on\n\nOh! there is a common theme.\nCause and Effect\n\nOccam's Razor\n\n\n
  47. Lets look at what might be going on\n\nOh! there is a common theme.\nCause and Effect\n\nOccam's Razor\n\n\n
  48. Lets look at what might be going on\n\nOh! there is a common theme.\nCause and Effect\n\nOccam's Razor\n\n\n
  49. Be nice to a device's battery - Save energy.\nSingle most important rule which we MUST obey when building a mobile web App.\nThis is why Flash is not on the iOS. \nThe one thing which has changed little for the modern smart phone over the past 3 years in how long the battery lasts on a single charge.\n\n\n
  50. Be nice to a device's battery - Save energy.\nSingle most important rule which we MUST obey when building a mobile web App.\nThis is why Flash is not on the iOS. \nThe one thing which has changed little for the modern smart phone over the past 3 years in how long the battery lasts on a single charge.\n\n\n
  51. It’s not just me talking about this.\n
  52. There a lots of optimization which we can make to our web app, some with have a greater impact on perceived performance than others. It’s useful to identify what techniques are going to most befit your users and work in implementing them first. There is no point on worrying about things way down here if you haven’t got the big stuff sorted.\n
  53. \n
  54. We can single out crunch points in our app.\nBasically there are 2 high level areas\nThen individual components which can be optimized.\n
  55. We can single out crunch points in our app.\nBasically there are 2 high level areas\nThen individual components which can be optimized.\n
  56. We can single out crunch points in our app.\nBasically there are 2 high level areas\nThen individual components which can be optimized.\n
  57. We can single out crunch points in our app.\nBasically there are 2 high level areas\nThen individual components which can be optimized.\n
  58. We can single out crunch points in our app.\nBasically there are 2 high level areas\nThen individual components which can be optimized.\n
  59. We can single out crunch points in our app.\nBasically there are 2 high level areas\nThen individual components which can be optimized.\n
  60. We can single out crunch points in our app.\nBasically there are 2 high level areas\nThen individual components which can be optimized.\n
  61. We can single out crunch points in our app.\nBasically there are 2 high level areas\nThen individual components which can be optimized.\n
  62. Of course if your app loads assets from the device then you can help minimize the load right off the bat. This is not always possible for example Browser based apps. There are also other reason why you may not want to do this, such as initial download size, keeping this content update etc.\n
  63. \n
  64. Why is it so bad?\n
  65. Bandwidth costs money (for all parties).\n\nThe network also impacts our Load phase, which is in most cases the slowest.\n\nUsers don’t always have good connection Think London Underground / Metro.\n\nJust spinning up the 3G attanna costs power.\n
  66. Bandwidth costs money (for all parties).\n\nThe network also impacts our Load phase, which is in most cases the slowest.\n\nUsers don’t always have good connection Think London Underground / Metro.\n\nJust spinning up the 3G attanna costs power.\n
  67. Bandwidth costs money (for all parties).\n\nThe network also impacts our Load phase, which is in most cases the slowest.\n\nUsers don’t always have good connection Think London Underground / Metro.\n\nJust spinning up the 3G attanna costs power.\n
  68. Bandwidth costs money (for all parties).\n\nThe network also impacts our Load phase, which is in most cases the slowest.\n\nUsers don’t always have good connection Think London Underground / Metro.\n\nJust spinning up the 3G attanna costs power.\n
  69. This is may be obvious. But in the mobile world simple network optimizations matter a LOT!\n\nThere are so many things we can do...\n
  70. This is may be obvious. But in the mobile world simple network optimizations matter a LOT!\n\nThere are so many things we can do...\n
  71. This is may be obvious. But in the mobile world simple network optimizations matter a LOT!\n\nThere are so many things we can do...\n
  72. This is may be obvious. But in the mobile world simple network optimizations matter a LOT!\n\nThere are so many things we can do...\n
  73. Enable Gzip - yep this one is so obvious, but it’s just a reminder.\nReduce number of requests...\n\nApplies to images, src, API data.\n\n\n\n
  74. Enable Gzip - yep this one is so obvious, but it’s just a reminder.\nReduce number of requests...\n\nApplies to images, src, API data.\n\n\n\n
  75. Enable Gzip - yep this one is so obvious, but it’s just a reminder.\nReduce number of requests...\n\nApplies to images, src, API data.\n\n\n\n
  76. Enable Gzip - yep this one is so obvious, but it’s just a reminder.\nReduce number of requests...\n\nApplies to images, src, API data.\n\n\n\n
  77. Enable Gzip - yep this one is so obvious, but it’s just a reminder.\nReduce number of requests...\n\nApplies to images, src, API data.\n\n\n\n
  78. Enable Gzip - yep this one is so obvious, but it’s just a reminder.\nReduce number of requests...\n\nApplies to images, src, API data.\n\n\n\n
  79. Enable Gzip - yep this one is so obvious, but it’s just a reminder.\nReduce number of requests...\n\nApplies to images, src, API data.\n\n\n\n
  80. Device specific: You can use @media ‘device-pixel-ratio’\nA problem this with is if you are also using cache manifests.\n\nUse CSS gradients, border-radius, ::before and ::after content to replace images.\n\nCSS marks demo\n
  81. Device specific: You can use @media ‘device-pixel-ratio’\nA problem this with is if you are also using cache manifests.\n\nUse CSS gradients, border-radius, ::before and ::after content to replace images.\n\nCSS marks demo\n
  82. Device specific: You can use @media ‘device-pixel-ratio’\nA problem this with is if you are also using cache manifests.\n\nUse CSS gradients, border-radius, ::before and ::after content to replace images.\n\nCSS marks demo\n
  83. Device specific: You can use @media ‘device-pixel-ratio’\nA problem this with is if you are also using cache manifests.\n\nUse CSS gradients, border-radius, ::before and ::after content to replace images.\n\nCSS marks demo\n
  84. Device specific: You can use @media ‘device-pixel-ratio’\nA problem this with is if you are also using cache manifests.\n\nUse CSS gradients, border-radius, ::before and ::after content to replace images.\n\nCSS marks demo\n
  85. Device specific: You can use @media ‘device-pixel-ratio’\nA problem this with is if you are also using cache manifests.\n\nUse CSS gradients, border-radius, ::before and ::after content to replace images.\n\nCSS marks demo\n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. Use a local version getItems.\n
  95. This sounds like a cop out, but sometimes it unavoidable.\nShow something sooner and indicate progress.\n\n\n
  96. Lets look at the usage cycle of a web app...\n\n\n
  97. Lets look at the usage cycle of a web app...\n\n\n
  98. Lets look at the usage cycle of a web app...\n\n\n
  99. Lets look at the usage cycle of a web app...\n\n\n
  100. Lets look at the usage cycle of a web app...\n\n\n
  101. Lets look at the usage cycle of a web app...\n\n\n
  102. Lets look at the usage cycle of a web app...\n\n\n
  103. Lets look at the usage cycle of a web app...\n\n\n
  104. What is Cool about Mobile is\nOne beast has been slain\nLess legacy - People don’t keep there phones for long, unlike desktop IE.\nBring on HTML5...\n
  105. Lets look at some of tools that HTML5 gives us to bring this all together.\n\n
  106. LocalStorage - KeyValue store, text content, 5Mb limit, well supported, lots of uses, Bing used it to store JavaScript and CSS content\nI use lot for caching JSON data.\n\nAppCache - can be useful, it’s very fiddly, but once you figure it out then it will help you a bit. The common consensus is that it needs more work.\n\nNetwork API - onLine / offLine checking and events\nConnection goes further - type off connection 3G, 4G, wifi - not well supported. \n\nBattery API - Samsung implemented, very early. \n\nWeb workers - Are good if you have a computational task which you don’t want to block UI thread.\n\n
  107. LocalStorage - KeyValue store, text content, 5Mb limit, well supported, lots of uses, Bing used it to store JavaScript and CSS content\nI use lot for caching JSON data.\n\nAppCache - can be useful, it’s very fiddly, but once you figure it out then it will help you a bit. The common consensus is that it needs more work.\n\nNetwork API - onLine / offLine checking and events\nConnection goes further - type off connection 3G, 4G, wifi - not well supported. \n\nBattery API - Samsung implemented, very early. \n\nWeb workers - Are good if you have a computational task which you don’t want to block UI thread.\n\n
  108. LocalStorage - KeyValue store, text content, 5Mb limit, well supported, lots of uses, Bing used it to store JavaScript and CSS content\nI use lot for caching JSON data.\n\nAppCache - can be useful, it’s very fiddly, but once you figure it out then it will help you a bit. The common consensus is that it needs more work.\n\nNetwork API - onLine / offLine checking and events\nConnection goes further - type off connection 3G, 4G, wifi - not well supported. \n\nBattery API - Samsung implemented, very early. \n\nWeb workers - Are good if you have a computational task which you don’t want to block UI thread.\n\n
  109. LocalStorage - KeyValue store, text content, 5Mb limit, well supported, lots of uses, Bing used it to store JavaScript and CSS content\nI use lot for caching JSON data.\n\nAppCache - can be useful, it’s very fiddly, but once you figure it out then it will help you a bit. The common consensus is that it needs more work.\n\nNetwork API - onLine / offLine checking and events\nConnection goes further - type off connection 3G, 4G, wifi - not well supported. \n\nBattery API - Samsung implemented, very early. \n\nWeb workers - Are good if you have a computational task which you don’t want to block UI thread.\n\n
  110. LocalStorage - KeyValue store, text content, 5Mb limit, well supported, lots of uses, Bing used it to store JavaScript and CSS content\nI use lot for caching JSON data.\n\nAppCache - can be useful, it’s very fiddly, but once you figure it out then it will help you a bit. The common consensus is that it needs more work.\n\nNetwork API - onLine / offLine checking and events\nConnection goes further - type off connection 3G, 4G, wifi - not well supported. \n\nBattery API - Samsung implemented, very early. \n\nWeb workers - Are good if you have a computational task which you don’t want to block UI thread.\n\n
  111. LocalStorage - KeyValue store, text content, 5Mb limit, well supported, lots of uses, Bing used it to store JavaScript and CSS content\nI use lot for caching JSON data.\n\nAppCache - can be useful, it’s very fiddly, but once you figure it out then it will help you a bit. The common consensus is that it needs more work.\n\nNetwork API - onLine / offLine checking and events\nConnection goes further - type off connection 3G, 4G, wifi - not well supported. \n\nBattery API - Samsung implemented, very early. \n\nWeb workers - Are good if you have a computational task which you don’t want to block UI thread.\n\n
  112. LocalStorage - KeyValue store, text content, 5Mb limit, well supported, lots of uses, Bing used it to store JavaScript and CSS content\nI use lot for caching JSON data.\n\nAppCache - can be useful, it’s very fiddly, but once you figure it out then it will help you a bit. The common consensus is that it needs more work.\n\nNetwork API - onLine / offLine checking and events\nConnection goes further - type off connection 3G, 4G, wifi - not well supported. \n\nBattery API - Samsung implemented, very early. \n\nWeb workers - Are good if you have a computational task which you don’t want to block UI thread.\n\n
  113. Compablity\n
  114. \n
  115. \n
  116. http://microjs.com/\n\nUse micro library, know what the library does.\n\nKnow the quality of the code.\nAvoid duplication of functionally.\n\nzepto, when.js, require.js, backbone.js...\n
  117. http://microjs.com/\n\nUse micro library, know what the library does.\n\nKnow the quality of the code.\nAvoid duplication of functionally.\n\nzepto, when.js, require.js, backbone.js...\n
  118. http://microjs.com/\n\nUse micro library, know what the library does.\n\nKnow the quality of the code.\nAvoid duplication of functionally.\n\nzepto, when.js, require.js, backbone.js...\n
  119. http://microjs.com/\n\nUse micro library, know what the library does.\n\nKnow the quality of the code.\nAvoid duplication of functionally.\n\nzepto, when.js, require.js, backbone.js...\n
  120. \n
  121. \n
  122. Whats happened is our big data payload request 16 is now coming from Localstorage and the other assets are coming for the AppCache.\n\nThere is still an issue with the parse time.\n\n
  123. So lets take a look at a couple of things which will affect a user’s experience interacting with our app after it has loaded.\n\nFirst up animation. I mentioned that we have limited hardware resources available, one thing we do have access it the device’s GPU (Graphics Processing Unit).\n\nIn the reality we shouldn’t be trying to do any kind of animation on a mobile device unless we can offload it to the GPU.\n
  124. We can make an element H/W accelerated by applying a CSS transform. This puts it on to the GPU as a surface or texture.\n\ndon’t put too much on it as this will cause textures to get flushed.\n\n
  125. We can make an element H/W accelerated by applying a CSS transform. This puts it on to the GPU as a surface or texture.\n\ndon’t put too much on it as this will cause textures to get flushed.\n\n
  126. We can make an element H/W accelerated by applying a CSS transform. This puts it on to the GPU as a surface or texture.\n\ndon’t put too much on it as this will cause textures to get flushed.\n\n
  127. We can make an element H/W accelerated by applying a CSS transform. This puts it on to the GPU as a surface or texture.\n\ndon’t put too much on it as this will cause textures to get flushed.\n\n
  128. Repaints can occur when ever a DOM style is updated.\nReflows (things like resizing of elements) can be more costly as they have to recalculate all the elements on the page.\n\nAvoid box shadows - Use border image or add element to a parent container and then don’t animate the contents so the can be saved as a texture.\n\nAvoid un-rendered content i.e. text-indent: -99999em - this makes the device render a large panel\n\nrequestAnimationFrame not tided to the UI thread, can be put to sleep / shutdown by the device. \n
  129. Repaints can occur when ever a DOM style is updated.\nReflows (things like resizing of elements) can be more costly as they have to recalculate all the elements on the page.\n\nAvoid box shadows - Use border image or add element to a parent container and then don’t animate the contents so the can be saved as a texture.\n\nAvoid un-rendered content i.e. text-indent: -99999em - this makes the device render a large panel\n\nrequestAnimationFrame not tided to the UI thread, can be put to sleep / shutdown by the device. \n
  130. Repaints can occur when ever a DOM style is updated.\nReflows (things like resizing of elements) can be more costly as they have to recalculate all the elements on the page.\n\nAvoid box shadows - Use border image or add element to a parent container and then don’t animate the contents so the can be saved as a texture.\n\nAvoid un-rendered content i.e. text-indent: -99999em - this makes the device render a large panel\n\nrequestAnimationFrame not tided to the UI thread, can be put to sleep / shutdown by the device. \n
  131. RE-USE DOM ELEMENTS.\n\nUse touch events - Don’t use mouse events, these incur a 300ms delay. Bill Fisher’s talk yesterday covered some really great ways to deal with touch events.\n\nAlso the when placing listeners. Its generally to add them to a single parent not rather than to individual elements. Libraries like Zepto or JQuery help you with this though Delegate and Live.\n\nTake advantage of the Event model, capture and bubble phase.\n\n
  132. Use touch events - Don’t use mouse events, these incur a 300ms delay.\n\nAlso the when placing listeners. Its generally to add them to a single parent not rather than to individual elements. Libraries like Zepto or JQuery help you with this though Delegate and Live.\n\nTake advantage of the Event model, capture and bubble phase.\n\nclosures\n
  133. \n
  134. You will need some kind of build process. I personally use ANT, cos I’m a sucker for XML, but you can use make, rake, jake... What’s important is that you need some kind of tool to transform your src code into something which you can deploy.\n\nWhat do we make our build do:\nResolve JS dependencies, concat, uglify, SASS\nBuild cache manifests.\nRun tests, JSLint, Jasmine + PhantomJS\nDeploy\n\nIssues you can find in minified code.\n\nBuild macros, pre processes.\n\ndebug and release builds.\n\n\n
  135. You will need some kind of build process. I personally use ANT, cos I’m a sucker for XML, but you can use make, rake, jake... What’s important is that you need some kind of tool to transform your src code into something which you can deploy.\n\nWhat do we make our build do:\nResolve JS dependencies, concat, uglify, SASS\nBuild cache manifests.\nRun tests, JSLint, Jasmine + PhantomJS\nDeploy\n\nIssues you can find in minified code.\n\nBuild macros, pre processes.\n\ndebug and release builds.\n\n\n
  136. Istat Menu\nTest in the real world\nAvoid the latest and greatest (aka 4S and 5)\n
  137. Istat Menu\nTest in the real world\nAvoid the latest and greatest (aka 4S and 5)\n
  138. Istat Menu\nTest in the real world\nAvoid the latest and greatest (aka 4S and 5)\n
  139. Istat Menu\nTest in the real world\nAvoid the latest and greatest (aka 4S and 5)\n
  140. Istat Menu\nTest in the real world\nAvoid the latest and greatest (aka 4S and 5)\n
  141. Istat Menu\nTest in the real world\nAvoid the latest and greatest (aka 4S and 5)\n
  142. Istat Menu\nTest in the real world\nAvoid the latest and greatest (aka 4S and 5)\n
  143. \n
  144. \n
  145. \n
  146. \n
  147. \n
  148. \n
  149. \n
  150. \n
  151. We are trying make 5* apps which people will tweet and blog about.\nOptimization is just a piece of the puzzle.\n
  152. \n
  153. \n