SlideShare a Scribd company logo
Tricks for mobile
  performance

     Josh Fraser
Hi. I’m Josh
 ‣   Cofounder & CEO of
 ‣   Find me on the web...
     ‣   @joshfraser on twitter
     ‣   joshfraser.com
     ‣   josh@torbit.com




@joshfraser | torbit.com
@joshfraser | torbit.com
@joshfraser | torbit.com
Josh Fraser: Mobile performance tricks
What’s special about mobile?




@joshfraser | torbit.com
Challenges on mobile
 ‣   Smaller screen
 ‣   Slower connections
     ‣   Lower bandwidth
     ‣   Higher latency
 ‣   Smaller cache sizes
 ‣   Lots of differences between devices


@joshfraser | torbit.com
My focus is on automated solutions




@joshfraser | torbit.com
Understanding differences
                    between devices




@joshfraser | torbit.com
Platform breakdown
                                           HP / Palm
                                             2.8%
                               Microsoft
                                 7.5%




                                                               Google
                                                               34.7%




                       Apple
                       25.5%




                                                        RIM
                                                       27.1%




                                                                        ComScore, May 2011

@joshfraser | torbit.com
Differences between devices
 ‣   Screen sizes
 ‣   Processor speeds
 ‣   Different browsers
 ‣   Different cache sizes
 ‣   3G vs. wifi
 ‣   What about tablets?

@joshfraser | torbit.com
Resizing images




@joshfraser | torbit.com
Resizing images




               Resized to 35%   Full size image

@joshfraser | torbit.com
Resizing images
 ‣   Finding the best ratio
 ‣   Replacement strategy
     ‣   Wait for onload
     ‣   Wait for onready
     ‣   Wait for a set amount of time
 ‣   Interlaced vs. low resolution place holders


@joshfraser | torbit.com
Lazy-loading below the fold




@joshfraser | torbit.com
Lazy-loading images
 ‣   Replace lower images with a placeholder
     ‣ Set width & height attributes on IMG tag to prevent reflows

 ‣   Determine “below-the-fold”
     ‣   Keep track of screen resolutions for each device
     ‣   Detect with JavaScript & remember with cookies
 ‣   Replacement strategy


@joshfraser | torbit.com
Using localStorage




@joshfraser | torbit.com
Using localStorage
 ‣   Technique used by Google, Facebook & Bing
 ‣   Gives you dedicated cache for domain
     ‣ Generally 5MB

 ‣   Reduce HTTP requests
     ‣ Include static resources with the initial HTML
     ‣   Use cookies to track which resources are in localStorage
     ‣   Best when automated

@joshfraser | torbit.com
How it works




@joshfraser | torbit.com
Using localStorage
 ‣   Send static resources as inline JavaScript
 ‣   For the JavaScript
     ‣ Use document.write for outputting JavaScript
 ‣ For   the CSS
     ‣ Replace the link to original CSS file with an empty style tag
     ‣ Use innerHTML to write contents

 ‣ Everything        is still executed in the correct order
@joshfraser | torbit.com
Benefits of localStorage
 ‣   Dramatically reduce HTTP requests
 ‣   Extend cache life to optimize return visits
 ‣   Safer than many other techniques used today




@joshfraser | torbit.com
Without localStorage




@joshfraser | torbit.com
With localStorage




                           2.2x faster




@joshfraser | torbit.com
Preloading content
                     for the next page view




@joshfraser | torbit.com
Preloading content
 ‣   Wait until onload
     ‣ Don’t slow down current page
 ‣   Predictive analysis
     ‣   Decide which page resources to preload based on historical
         data
 ‣   Use localStorage
 ‣   Be respectful of metered bandwidth

@joshfraser | torbit.com
When to inline or externalize
                  CSS or JavaScript




@joshfraser | torbit.com
Inline vs. external
 External



 Inline




@joshfraser | torbit.com
Inline vs. external
 ‣   Separation of code is nice for development
 ‣   External resources allow for future cache hits
 ‣   Extra HTTP requests are expensive




@joshfraser | torbit.com
Use localStorage
                 for the best of both worlds




@joshfraser | torbit.com
Iframes




@joshfraser | torbit.com
Iframes
 ‣   Often used to get around cross-domain issues
     ‣ Facebook like button, Google +1, etc
 ‣   Should be avoided even more on mobile
 ‣   Can often be lazy-loaded




@joshfraser | torbit.com
Loading indicators




@joshfraser | torbit.com
Trade-offs




@joshfraser | torbit.com
Trade-offs
 ‣   Preloading
     ‣ Fast user experience vs. high cost of bandwidth
 ‣   Image quality
     ‣ Faster loading vs. better quality
 ‣   This page view vs next page view
 ‣   Requirements & results vary for every site

@joshfraser | torbit.com
The best way to deal with trade-offs
     is to use automation and measurement




@joshfraser | torbit.com
The easiest way to automate
 ‣   Visit torbit.com
 ‣   Sign up using the invite code “velocity”
 ‣   This week: use coupon “velocity” for 20% off!




@joshfraser | torbit.com
In summary
 ‣   Reduce the # of HTTP requests
 ‣   Reduce file sizes
 ‣   Take advantage of localStorage
 ‣   Automate




@joshfraser | torbit.com
Thank you!

                             @joshfraser
                           josh@torbit.com



@joshfraser | torbit.com
Questions?

                             @joshfraser
                           josh@torbit.com



@joshfraser | torbit.com

More Related Content

PDF
6 key learnings for responsive webdesign
PDF
Performance Optimization for Mobile Web | Fresh Tilled Soil
PDF
Presentation1
PPTX
How to make your website blazing fast
PPS
Cerâmica Contemporânea - Carlos Neto Ana Lousada
PPT
Designing Great Forms
KEY
Yo ho ho and a few billion pageviews of RUM
PPT
Snakes and Staircases
6 key learnings for responsive webdesign
Performance Optimization for Mobile Web | Fresh Tilled Soil
Presentation1
How to make your website blazing fast
Cerâmica Contemporânea - Carlos Neto Ana Lousada
Designing Great Forms
Yo ho ho and a few billion pageviews of RUM
Snakes and Staircases

Similar to Josh Fraser: Mobile performance tricks (20)

PDF
Extreme Web Performance for Mobile Devices - Velocity Barcelona 2014
PPTX
High Performance Mobile Web
PDF
Extreme Web Performance for Mobile Devices - Velocity NY
PDF
针对iPad平台的高性能网站架构
KEY
W3C Mobile Web technologies
PDF
Unravelling Mobile Web Performance
PPTX
How To Be an HTML5 Mobile Cloud Champion
KEY
Faster Frontends
PDF
Mobile Web Speed Bumps
KEY
Speed is Essential for a Great Web Experience
PDF
Everything You Know is Not Quite Right Anymore: Rethinking Best Web Practices...
PDF
Everything You Know is Not Quite Right Anymore: Rethinking Best Practices to ...
PDF
Speed is Essential for a Great Web Experience (Canvas Conf Version)
PDF
Mobile WPO
PDF
Going Fast on the Mobile Web
PPTX
Top Tips to Deliver Quality Web Experiences From IE 9 to the iPhone
PDF
Extreme Web Performance for Mobile Device Fluent 2015
PDF
The Need for Speed, Optimizing the User Experience pt2 - UXPA Boston 2014 - J...
PDF
Optimizing for a faster user experience Pt 2: How-to.
PDF
Web Anywhere: Mobile Optimisation With HTML5, CSS3, JavaScript
Extreme Web Performance for Mobile Devices - Velocity Barcelona 2014
High Performance Mobile Web
Extreme Web Performance for Mobile Devices - Velocity NY
针对iPad平台的高性能网站架构
W3C Mobile Web technologies
Unravelling Mobile Web Performance
How To Be an HTML5 Mobile Cloud Champion
Faster Frontends
Mobile Web Speed Bumps
Speed is Essential for a Great Web Experience
Everything You Know is Not Quite Right Anymore: Rethinking Best Web Practices...
Everything You Know is Not Quite Right Anymore: Rethinking Best Practices to ...
Speed is Essential for a Great Web Experience (Canvas Conf Version)
Mobile WPO
Going Fast on the Mobile Web
Top Tips to Deliver Quality Web Experiences From IE 9 to the iPhone
Extreme Web Performance for Mobile Device Fluent 2015
The Need for Speed, Optimizing the User Experience pt2 - UXPA Boston 2014 - J...
Optimizing for a faster user experience Pt 2: How-to.
Web Anywhere: Mobile Optimisation With HTML5, CSS3, JavaScript
Ad

Recently uploaded (20)

PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
August Patch Tuesday
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
Machine Learning_overview_presentation.pptx
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
Tartificialntelligence_presentation.pptx
A comparative study of natural language inference in Swahili using monolingua...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
August Patch Tuesday
Network Security Unit 5.pdf for BCA BBA.
SOPHOS-XG Firewall Administrator PPT.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
NewMind AI Weekly Chronicles - August'25-Week II
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
TLE Review Electricity (Electricity).pptx
Heart disease approach using modified random forest and particle swarm optimi...
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Programs and apps: productivity, graphics, security and other tools
Digital-Transformation-Roadmap-for-Companies.pptx
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Univ-Connecticut-ChatGPT-Presentaion.pdf
Machine Learning_overview_presentation.pptx
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Tartificialntelligence_presentation.pptx
Ad

Josh Fraser: Mobile performance tricks

  • 1. Tricks for mobile performance Josh Fraser
  • 2. Hi. I’m Josh ‣ Cofounder & CEO of ‣ Find me on the web... ‣ @joshfraser on twitter ‣ joshfraser.com ‣ josh@torbit.com @joshfraser | torbit.com
  • 6. What’s special about mobile? @joshfraser | torbit.com
  • 7. Challenges on mobile ‣ Smaller screen ‣ Slower connections ‣ Lower bandwidth ‣ Higher latency ‣ Smaller cache sizes ‣ Lots of differences between devices @joshfraser | torbit.com
  • 8. My focus is on automated solutions @joshfraser | torbit.com
  • 9. Understanding differences between devices @joshfraser | torbit.com
  • 10. Platform breakdown HP / Palm 2.8% Microsoft 7.5% Google 34.7% Apple 25.5% RIM 27.1% ComScore, May 2011 @joshfraser | torbit.com
  • 11. Differences between devices ‣ Screen sizes ‣ Processor speeds ‣ Different browsers ‣ Different cache sizes ‣ 3G vs. wifi ‣ What about tablets? @joshfraser | torbit.com
  • 13. Resizing images Resized to 35% Full size image @joshfraser | torbit.com
  • 14. Resizing images ‣ Finding the best ratio ‣ Replacement strategy ‣ Wait for onload ‣ Wait for onready ‣ Wait for a set amount of time ‣ Interlaced vs. low resolution place holders @joshfraser | torbit.com
  • 15. Lazy-loading below the fold @joshfraser | torbit.com
  • 16. Lazy-loading images ‣ Replace lower images with a placeholder ‣ Set width & height attributes on IMG tag to prevent reflows ‣ Determine “below-the-fold” ‣ Keep track of screen resolutions for each device ‣ Detect with JavaScript & remember with cookies ‣ Replacement strategy @joshfraser | torbit.com
  • 18. Using localStorage ‣ Technique used by Google, Facebook & Bing ‣ Gives you dedicated cache for domain ‣ Generally 5MB ‣ Reduce HTTP requests ‣ Include static resources with the initial HTML ‣ Use cookies to track which resources are in localStorage ‣ Best when automated @joshfraser | torbit.com
  • 19. How it works @joshfraser | torbit.com
  • 20. Using localStorage ‣ Send static resources as inline JavaScript ‣ For the JavaScript ‣ Use document.write for outputting JavaScript ‣ For the CSS ‣ Replace the link to original CSS file with an empty style tag ‣ Use innerHTML to write contents ‣ Everything is still executed in the correct order @joshfraser | torbit.com
  • 21. Benefits of localStorage ‣ Dramatically reduce HTTP requests ‣ Extend cache life to optimize return visits ‣ Safer than many other techniques used today @joshfraser | torbit.com
  • 23. With localStorage 2.2x faster @joshfraser | torbit.com
  • 24. Preloading content for the next page view @joshfraser | torbit.com
  • 25. Preloading content ‣ Wait until onload ‣ Don’t slow down current page ‣ Predictive analysis ‣ Decide which page resources to preload based on historical data ‣ Use localStorage ‣ Be respectful of metered bandwidth @joshfraser | torbit.com
  • 26. When to inline or externalize CSS or JavaScript @joshfraser | torbit.com
  • 27. Inline vs. external External Inline @joshfraser | torbit.com
  • 28. Inline vs. external ‣ Separation of code is nice for development ‣ External resources allow for future cache hits ‣ Extra HTTP requests are expensive @joshfraser | torbit.com
  • 29. Use localStorage for the best of both worlds @joshfraser | torbit.com
  • 31. Iframes ‣ Often used to get around cross-domain issues ‣ Facebook like button, Google +1, etc ‣ Should be avoided even more on mobile ‣ Can often be lazy-loaded @joshfraser | torbit.com
  • 34. Trade-offs ‣ Preloading ‣ Fast user experience vs. high cost of bandwidth ‣ Image quality ‣ Faster loading vs. better quality ‣ This page view vs next page view ‣ Requirements & results vary for every site @joshfraser | torbit.com
  • 35. The best way to deal with trade-offs is to use automation and measurement @joshfraser | torbit.com
  • 36. The easiest way to automate ‣ Visit torbit.com ‣ Sign up using the invite code “velocity” ‣ This week: use coupon “velocity” for 20% off! @joshfraser | torbit.com
  • 37. In summary ‣ Reduce the # of HTTP requests ‣ Reduce file sizes ‣ Take advantage of localStorage ‣ Automate @joshfraser | torbit.com
  • 38. Thank you! @joshfraser josh@torbit.com @joshfraser | torbit.com
  • 39. Questions? @joshfraser josh@torbit.com @joshfraser | torbit.com