SlideShare a Scribd company logo
Building Highly
                      Optimized Mobile Web
                              Apps
                                Glan Thomas
                           Future Insights Live 2012



Thursday, May 3, 12
About me
                      ... Why I am interested in this stuff




Thursday, May 3, 12
Thursday, May 3, 12
Thursday, May 3, 12
What is a Mobile Web
                              App?


Thursday, May 3, 12
Browser based
Thursday, May 3, 12
Webview
Thursday, May 3, 12
What’s it like going
                      from the desktop to
                          mobile web?


Thursday, May 3, 12
Why am interested in
                             this


                                         © Universal Pictures
Thursday, May 3, 12
What are we trying to
                           optimize?


Thursday, May 3, 12
Guest Experience
                              http://www.flickr.com/photos/stuckincustoms/518435043/
Thursday, May 3, 12
The	 5	 Great	 Mobile	 
                Development	 Challenges


Thursday, May 3, 12
➊ Limited
                      CPU and
                      memory
                      resources




Thursday, May 3, 12
➋ Variety of
                 Display Densities



Thursday, May 3, 12
➌ High
      Network
      Latency




                      http://www.qsl.net/ylradio/archives/YLstor/images/radioroom.jpg
Thursday, May 3, 12
➍ Harder
                      to Debug




                      http://www.flickr.com/photos/youraccount/3939769126/
Thursday, May 3, 12
➎  Matching
                      Users’ Expectations

                                   © DreamWorks Pictures / 20th Century Fox
Thursday, May 3, 12
What if we don’t do
      anything?

                      ✘ Long load times
                      ✘ Partial content
                        appearing
                      ✘ Unresponsive UI
                      ✘ Jittery animations


Thursday, May 3, 12
But It gets worse...
                      • Unnecessary data usage
                      • Decreased battery life
http://www.flickr.com/photos/flydime/4670141424/
Thursday, May 3, 12
“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
Thursday, May 3, 12
๏ 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
Thursday, May 3, 12
PRIME
                      DIRECTIVE
                      "Be green and
                       respect the
                         battery"




                        © CBS Paramount Television / Paramount Pictures
Thursday, May 3, 12
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
             phone.                                                                 be as expensive to render as images. Moreover, dynamic Javascript
Thursday, May 3, 12                                                                 requests (in the form of                       ) can greatly increase
Where to start?
                      Perceived Lag / Power Drain




                                                    Optimizations




Thursday, May 3, 12
Crunch Points

                            Loading                        User Interaction


                Network   Parsing     Execution   Rendering Animation   Events




Thursday, May 3, 12
Tip
                      Don’t take the network for granted




Thursday, May 3, 12
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/
Thursday, May 3, 12
How do you
   solve a
   problem like
   the network?

                      Do everything Steve
                      Souders tells you to.

Thursday, May 3, 12
• 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.

Thursday, May 3, 12
Images
                      • Use sprites to reduce requests.
                      • Use optimization tools (ImageOptim,
                        ImageAlpha).
                      • Device specific images.
                      • Base64 inline (pros & cons).
                      • Use CSS masks for alpha.
                      • JPEGs use less power.
Thursday, May 3, 12
Original PNG       JPEG      3bit PNG Mask
              33Kb           19Kb           4.7Kb
                         --- 23.7Kb ~ 29% saving ---
Thursday, May 3, 12
Tip
                      If you really must make the user wait,
                                  show something.




Thursday, May 3, 12
Ideal App Usage Cycle
                      •   Load App (HTML & CSS)

                      •   Render

                      •   Load Source (JS)

                      •   Parse

                      •   Execute

                      •   Parallel Operations

                          •   User Events

                          •   Deferred Loads (data and images)

Thursday, May 3, 12
It is
     not
     all
     bad
     news
Thursday, May 3, 12
Tip
     Use HTML5 and other goodies




Thursday, May 3, 12
HTML5
                      • LocalStorage
                      • AppCache
                      • Network / Connection API
                      • Battery API
                      • Things we don’t need libraries for:
                       • JSON, QuerySelector, ClassLists
Thursday, May 3, 12
JavaScript Libraries

                      • Modular
                      • Lightweight
                      • Maintained
                      • Understandable

Thursday, May 3, 12
Tip
                      Don't animate anything that you can't reliably
                                  offload to the GPU




Thursday, May 3, 12
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)




Thursday, May 3, 12
Keeping things on the
                              GPU
                      • Reduce repaints and reflows
                      • Avoid box shadows (or use them carefully)
                      • Avoid opacity/transparency fades.
                      • Avoid garbage collection during animations

Thursday, May 3, 12
Tip
                      Keep the DOM simple and use event
                               listeners carefully




Thursday, May 3, 12
Putting things together



Thursday, May 3, 12
Build
    process

            • Build process
            • Testing and
                      debugging



                                  http://floridakeysgirl.com/wp-content/uploads/2010/10/IMG_1147-e1288555102991.jpg
Thursday, May 3, 12
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

Thursday, May 3, 12
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.


Thursday, May 3, 12
Target Excellence



Thursday, May 3, 12
Thanks for all the fish




    Glan Thomas @glan

    Future Insights Live 2012

    Las Vegas, NV
Thursday, May 3, 12
Useful Links
                      •   Steve Souders
                          http://stevesouders.com

                      •   Estelle Weyl
                          @estellevw

                      •   Joe Hewitt
                          http://joehewitt.com/2011/10/05/fast-animation-with-ios-webkit

                      •   Jake Archibald
                          @jaffathecake

                      • Thomas Fuchs
                        http://mir.aculo.us/

                      •   Who Killed My Battery
                          http://www2012.wwwconference.org/proceedings/proceedings/p41.pdf

Thursday, May 3, 12
Disney is hiring



Thursday, May 3, 12

More Related Content

Similar to Building Highly Optimized Mobile Web Apps

That's Web? Extreme Optimization for the Mobile Web (Oct 2012)
That's Web? Extreme Optimization for the Mobile Web (Oct 2012)That's Web? Extreme Optimization for the Mobile Web (Oct 2012)
That's Web? Extreme Optimization for the Mobile Web (Oct 2012)
Glan Thomas
 
Faster mobile sites
Faster mobile sitesFaster mobile sites
Faster mobile sites
Matthew Farina
 
Universal Design Final
Universal Design FinalUniversal Design Final
Universal Design Final
guestd9aa5
 
jQuery Mobile, Backbone.js, and ASP.NET MVC
jQuery Mobile, Backbone.js, and ASP.NET MVCjQuery Mobile, Backbone.js, and ASP.NET MVC
jQuery Mobile, Backbone.js, and ASP.NET MVC
Troy Miles
 
Web performance optimization
Web performance optimizationWeb performance optimization
Web performance optimization
Massimo Iacolare
 
Designing for performance: Database Related Worst Practices
Designing for performance: Database Related Worst PracticesDesigning for performance: Database Related Worst Practices
Designing for performance: Database Related Worst Practices
Trivadis
 
A 3-screen approach to Web performance optimization
A 3-screen approach to Web performance optimizationA 3-screen approach to Web performance optimization
A 3-screen approach to Web performance optimization
Keynote Mobile Testing
 
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
 
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
 
The future of cloud computing - Jisc Digifest 2016
The future of cloud computing - Jisc Digifest 2016The future of cloud computing - Jisc Digifest 2016
The future of cloud computing - Jisc Digifest 2016
Jisc
 
Vehicular Delay Tolerant Network (VDTN): Routing Perspectives
Vehicular Delay Tolerant Network (VDTN):Routing PerspectivesVehicular Delay Tolerant Network (VDTN):Routing Perspectives
Vehicular Delay Tolerant Network (VDTN): Routing Perspectives
Syed Hassan Ahmed
 
20090309berkeley
20090309berkeley20090309berkeley
20090309berkeley
Jeff Hammerbacher
 
Front end performance improvements
Front end performance improvementsFront end performance improvements
Front end performance improvements
Matthew Farina
 
Front-End Performance Starts On the Server
Front-End Performance Starts On the ServerFront-End Performance Starts On the Server
Front-End Performance Starts On the Server
Jon Arne Sæterås
 
Mobile Web Design. Less is More
Mobile Web Design. Less is MoreMobile Web Design. Less is More
Mobile Web Design. Less is More
Kula Partners
 
Mobile Web Browsing Based On Content Preserving With Reduced Cost
Mobile Web Browsing Based On Content Preserving With Reduced CostMobile Web Browsing Based On Content Preserving With Reduced Cost
Mobile Web Browsing Based On Content Preserving With Reduced Cost
Eswar Publications
 
Drupal for enterprise
Drupal for enterpriseDrupal for enterprise
Drupal for enterprise
Fathoni Musyaffa
 
NATO IST Symposium 2013
NATO IST Symposium 2013NATO IST Symposium 2013
NATO IST Symposium 2013
Patrick Chanezon
 
Cloud computing Sustainabilty
Cloud computing SustainabiltyCloud computing Sustainabilty
Cloud computing Sustainabilty
darkpros
 
Assessment to Delegate the Task to Cloud for Increasing Energy Efficiency of ...
Assessment to Delegate the Task to Cloud for Increasing Energy Efficiency of ...Assessment to Delegate the Task to Cloud for Increasing Energy Efficiency of ...
Assessment to Delegate the Task to Cloud for Increasing Energy Efficiency of ...
IRJET Journal
 

Similar to Building Highly Optimized Mobile Web Apps (20)

That's Web? Extreme Optimization for the Mobile Web (Oct 2012)
That's Web? Extreme Optimization for the Mobile Web (Oct 2012)That's Web? Extreme Optimization for the Mobile Web (Oct 2012)
That's Web? Extreme Optimization for the Mobile Web (Oct 2012)
 
Faster mobile sites
Faster mobile sitesFaster mobile sites
Faster mobile sites
 
Universal Design Final
Universal Design FinalUniversal Design Final
Universal Design Final
 
jQuery Mobile, Backbone.js, and ASP.NET MVC
jQuery Mobile, Backbone.js, and ASP.NET MVCjQuery Mobile, Backbone.js, and ASP.NET MVC
jQuery Mobile, Backbone.js, and ASP.NET MVC
 
Web performance optimization
Web performance optimizationWeb performance optimization
Web performance optimization
 
Designing for performance: Database Related Worst Practices
Designing for performance: Database Related Worst PracticesDesigning for performance: Database Related Worst Practices
Designing for performance: Database Related Worst Practices
 
A 3-screen approach to Web performance optimization
A 3-screen approach to Web performance optimizationA 3-screen approach to Web performance optimization
A 3-screen approach to Web performance optimization
 
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 ...
 
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...
 
The future of cloud computing - Jisc Digifest 2016
The future of cloud computing - Jisc Digifest 2016The future of cloud computing - Jisc Digifest 2016
The future of cloud computing - Jisc Digifest 2016
 
Vehicular Delay Tolerant Network (VDTN): Routing Perspectives
Vehicular Delay Tolerant Network (VDTN):Routing PerspectivesVehicular Delay Tolerant Network (VDTN):Routing Perspectives
Vehicular Delay Tolerant Network (VDTN): Routing Perspectives
 
20090309berkeley
20090309berkeley20090309berkeley
20090309berkeley
 
Front end performance improvements
Front end performance improvementsFront end performance improvements
Front end performance improvements
 
Front-End Performance Starts On the Server
Front-End Performance Starts On the ServerFront-End Performance Starts On the Server
Front-End Performance Starts On the Server
 
Mobile Web Design. Less is More
Mobile Web Design. Less is MoreMobile Web Design. Less is More
Mobile Web Design. Less is More
 
Mobile Web Browsing Based On Content Preserving With Reduced Cost
Mobile Web Browsing Based On Content Preserving With Reduced CostMobile Web Browsing Based On Content Preserving With Reduced Cost
Mobile Web Browsing Based On Content Preserving With Reduced Cost
 
Drupal for enterprise
Drupal for enterpriseDrupal for enterprise
Drupal for enterprise
 
NATO IST Symposium 2013
NATO IST Symposium 2013NATO IST Symposium 2013
NATO IST Symposium 2013
 
Cloud computing Sustainabilty
Cloud computing SustainabiltyCloud computing Sustainabilty
Cloud computing Sustainabilty
 
Assessment to Delegate the Task to Cloud for Increasing Energy Efficiency of ...
Assessment to Delegate the Task to Cloud for Increasing Energy Efficiency of ...Assessment to Delegate the Task to Cloud for Increasing Energy Efficiency of ...
Assessment to Delegate the Task to Cloud for Increasing Energy Efficiency of ...
 

Recently uploaded

UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 

Building Highly Optimized Mobile Web Apps

  • 1. Building Highly Optimized Mobile Web Apps Glan Thomas Future Insights Live 2012 Thursday, May 3, 12
  • 2. About me ... Why I am interested in this stuff Thursday, May 3, 12
  • 5. What is a Mobile Web App? Thursday, May 3, 12
  • 8. What’s it like going from the desktop to mobile web? Thursday, May 3, 12
  • 9. Why am interested in this © Universal Pictures Thursday, May 3, 12
  • 10. What are we trying to optimize? Thursday, May 3, 12
  • 11. Guest Experience http://www.flickr.com/photos/stuckincustoms/518435043/ Thursday, May 3, 12
  • 12. The 5 Great Mobile Development Challenges Thursday, May 3, 12
  • 13. ➊ Limited CPU and memory resources Thursday, May 3, 12
  • 14. ➋ Variety of Display Densities Thursday, May 3, 12
  • 15. ➌ High Network Latency http://www.qsl.net/ylradio/archives/YLstor/images/radioroom.jpg Thursday, May 3, 12
  • 16. ➍ Harder to Debug http://www.flickr.com/photos/youraccount/3939769126/ Thursday, May 3, 12
  • 17. ➎ Matching Users’ Expectations © DreamWorks Pictures / 20th Century Fox Thursday, May 3, 12
  • 18. What if we don’t do anything? ✘ Long load times ✘ Partial content appearing ✘ Unresponsive UI ✘ Jittery animations Thursday, May 3, 12
  • 19. But It gets worse... • Unnecessary data usage • Decreased battery life http://www.flickr.com/photos/flydime/4670141424/ Thursday, May 3, 12
  • 20. “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 Thursday, May 3, 12
  • 21. ๏ 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 Thursday, May 3, 12
  • 22. PRIME DIRECTIVE "Be green and respect the battery" © CBS Paramount Television / Paramount Pictures Thursday, May 3, 12
  • 23. 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 phone. be as expensive to render as images. Moreover, dynamic Javascript Thursday, May 3, 12 requests (in the form of ) can greatly increase
  • 24. Where to start? Perceived Lag / Power Drain Optimizations Thursday, May 3, 12
  • 25. Crunch Points Loading User Interaction Network Parsing Execution Rendering Animation Events Thursday, May 3, 12
  • 26. Tip Don’t take the network for granted Thursday, May 3, 12
  • 27. 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/ Thursday, May 3, 12
  • 28. How do you solve a problem like the network? Do everything Steve Souders tells you to. Thursday, May 3, 12
  • 29. • 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. Thursday, May 3, 12
  • 30. Images • Use sprites to reduce requests. • Use optimization tools (ImageOptim, ImageAlpha). • Device specific images. • Base64 inline (pros & cons). • Use CSS masks for alpha. • JPEGs use less power. Thursday, May 3, 12
  • 31. Original PNG JPEG 3bit PNG Mask 33Kb 19Kb 4.7Kb --- 23.7Kb ~ 29% saving --- Thursday, May 3, 12
  • 32. Tip If you really must make the user wait, show something. Thursday, May 3, 12
  • 33. Ideal App Usage Cycle • Load App (HTML & CSS) • Render • Load Source (JS) • Parse • Execute • Parallel Operations • User Events • Deferred Loads (data and images) Thursday, May 3, 12
  • 34. It is not all bad news Thursday, May 3, 12
  • 35. Tip Use HTML5 and other goodies Thursday, May 3, 12
  • 36. HTML5 • LocalStorage • AppCache • Network / Connection API • Battery API • Things we don’t need libraries for: • JSON, QuerySelector, ClassLists Thursday, May 3, 12
  • 37. JavaScript Libraries • Modular • Lightweight • Maintained • Understandable Thursday, May 3, 12
  • 38. Tip Don't animate anything that you can't reliably offload to the GPU Thursday, May 3, 12
  • 39. 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) Thursday, May 3, 12
  • 40. Keeping things on the GPU • Reduce repaints and reflows • Avoid box shadows (or use them carefully) • Avoid opacity/transparency fades. • Avoid garbage collection during animations Thursday, May 3, 12
  • 41. Tip Keep the DOM simple and use event listeners carefully Thursday, May 3, 12
  • 43. Build process • Build process • Testing and debugging http://floridakeysgirl.com/wp-content/uploads/2010/10/IMG_1147-e1288555102991.jpg Thursday, May 3, 12
  • 44. 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 Thursday, May 3, 12
  • 45. 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. Thursday, May 3, 12
  • 47. Thanks for all the fish Glan Thomas @glan Future Insights Live 2012 Las Vegas, NV Thursday, May 3, 12
  • 48. Useful Links • Steve Souders http://stevesouders.com • Estelle Weyl @estellevw • Joe Hewitt http://joehewitt.com/2011/10/05/fast-animation-with-ios-webkit • Jake Archibald @jaffathecake • Thomas Fuchs http://mir.aculo.us/ • Who Killed My Battery http://www2012.wwwconference.org/proceedings/proceedings/p41.pdf Thursday, May 3, 12