SlideShare a Scribd company logo
1 of 39
Download to read offline
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
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

Similar to Josh Fraser: Mobile performance tricks

Optimizing content for the "mobile web"
Optimizing content for the "mobile web"Optimizing content for the "mobile web"
Optimizing content for the "mobile web"Chris Mills
 
Web performance optimization for modern web applications
Web performance optimization for modern web applicationsWeb performance optimization for modern web applications
Web performance optimization for modern web applicationsChris Love
 
Extreme Web Performance for Mobile Device Fluent 2015
Extreme Web Performance for Mobile Device Fluent 2015Extreme Web Performance for Mobile Device Fluent 2015
Extreme Web Performance for Mobile Device Fluent 2015Maximiliano Firtman
 
Responsive webdesign
Responsive webdesignResponsive webdesign
Responsive webdesignBart De Waele
 
Responsive Webdesign - UXtour Microsoft
Responsive Webdesign - UXtour MicrosoftResponsive Webdesign - UXtour Microsoft
Responsive Webdesign - UXtour MicrosoftThomas Deceuninck
 
Extreme Web Performance for Mobile Devices
Extreme Web Performance for Mobile DevicesExtreme Web Performance for Mobile Devices
Extreme Web Performance for Mobile DevicesMaximiliano Firtman
 
Mobile Web & HTML5 Performance Optimization
Mobile Web & HTML5 Performance OptimizationMobile Web & HTML5 Performance Optimization
Mobile Web & HTML5 Performance OptimizationMaximiliano Firtman
 
Front-End Performance Checklist 2020
Front-End Performance Checklist 2020Front-End Performance Checklist 2020
Front-End Performance Checklist 2020Harsha MV
 
Stapling and patching the web of now - ForwardJS3, San Francisco
Stapling and patching the web of now - ForwardJS3, San FranciscoStapling and patching the web of now - ForwardJS3, San Francisco
Stapling and patching the web of now - ForwardJS3, San FranciscoChristian Heilmann
 
Mobile Web High Performance
Mobile Web High PerformanceMobile Web High Performance
Mobile Web High PerformanceAmjad Rafique
 
Extreme Web Performance for Mobile Devices - Velocity Barcelona 2014
Extreme Web Performance for Mobile Devices - Velocity Barcelona 2014Extreme Web Performance for Mobile Devices - Velocity Barcelona 2014
Extreme Web Performance for Mobile Devices - Velocity Barcelona 2014Maximiliano Firtman
 
Improving frontend performance
Improving frontend performanceImproving frontend performance
Improving frontend performanceSagar Desarda
 
Mobile for PHP developers
Mobile for PHP developersMobile for PHP developers
Mobile for PHP developersIvo Jansch
 
Mobile Optimization Tips from Yottaa - MEGMeetup #1
Mobile Optimization Tips from Yottaa - MEGMeetup #1Mobile Optimization Tips from Yottaa - MEGMeetup #1
Mobile Optimization Tips from Yottaa - MEGMeetup #1Yottaa
 
Crawl Budget Conqueror - Take Control of Your Crawl Budget
Crawl Budget Conqueror - Take Control of Your Crawl BudgetCrawl Budget Conqueror - Take Control of Your Crawl Budget
Crawl Budget Conqueror - Take Control of Your Crawl BudgetCatalyst
 
Performance Tuning Web Apps - The Need For Speed
Performance Tuning Web Apps - The Need For SpeedPerformance Tuning Web Apps - The Need For Speed
Performance Tuning Web Apps - The Need For SpeedVijay Rayapati
 
Boosting your conversion rate through web performance improvements
Boosting your conversion rate through web performance improvementsBoosting your conversion rate through web performance improvements
Boosting your conversion rate through web performance improvementsAlyss Noland
 
Responsive Web Design - Why and How
Responsive Web Design - Why and HowResponsive Web Design - Why and How
Responsive Web Design - Why and HowJudi Wunderlich
 
Beyond the Desktop: Sites and Apps for Phones and Tablets
Beyond the Desktop: Sites and Apps for Phones and TabletsBeyond the Desktop: Sites and Apps for Phones and Tablets
Beyond the Desktop: Sites and Apps for Phones and TabletsWebvanta
 

Similar to Josh Fraser: Mobile performance tricks (20)

Optimizing content for the "mobile web"
Optimizing content for the "mobile web"Optimizing content for the "mobile web"
Optimizing content for the "mobile web"
 
Web performance optimization for modern web applications
Web performance optimization for modern web applicationsWeb performance optimization for modern web applications
Web performance optimization for modern web applications
 
Extreme Web Performance for Mobile Device Fluent 2015
Extreme Web Performance for Mobile Device Fluent 2015Extreme Web Performance for Mobile Device Fluent 2015
Extreme Web Performance for Mobile Device Fluent 2015
 
Responsive webdesign
Responsive webdesignResponsive webdesign
Responsive webdesign
 
Responsive Webdesign - UXtour Microsoft
Responsive Webdesign - UXtour MicrosoftResponsive Webdesign - UXtour Microsoft
Responsive Webdesign - UXtour Microsoft
 
Extreme Web Performance for Mobile Devices
Extreme Web Performance for Mobile DevicesExtreme Web Performance for Mobile Devices
Extreme Web Performance for Mobile Devices
 
Mobile Web & HTML5 Performance Optimization
Mobile Web & HTML5 Performance OptimizationMobile Web & HTML5 Performance Optimization
Mobile Web & HTML5 Performance Optimization
 
Front-End Performance Checklist 2020
Front-End Performance Checklist 2020Front-End Performance Checklist 2020
Front-End Performance Checklist 2020
 
Stapling and patching the web of now - ForwardJS3, San Francisco
Stapling and patching the web of now - ForwardJS3, San FranciscoStapling and patching the web of now - ForwardJS3, San Francisco
Stapling and patching the web of now - ForwardJS3, San Francisco
 
Mobile Web High Performance
Mobile Web High PerformanceMobile Web High Performance
Mobile Web High Performance
 
Extreme Web Performance for Mobile Devices - Velocity Barcelona 2014
Extreme Web Performance for Mobile Devices - Velocity Barcelona 2014Extreme Web Performance for Mobile Devices - Velocity Barcelona 2014
Extreme Web Performance for Mobile Devices - Velocity Barcelona 2014
 
Improving frontend performance
Improving frontend performanceImproving frontend performance
Improving frontend performance
 
Mobile for PHP developers
Mobile for PHP developersMobile for PHP developers
Mobile for PHP developers
 
Mobile Optimization Tips from Yottaa - MEGMeetup #1
Mobile Optimization Tips from Yottaa - MEGMeetup #1Mobile Optimization Tips from Yottaa - MEGMeetup #1
Mobile Optimization Tips from Yottaa - MEGMeetup #1
 
Crawl Budget Conqueror - Take Control of Your Crawl Budget
Crawl Budget Conqueror - Take Control of Your Crawl BudgetCrawl Budget Conqueror - Take Control of Your Crawl Budget
Crawl Budget Conqueror - Take Control of Your Crawl Budget
 
73 Less Fugly Epicenter
73 Less Fugly   Epicenter73 Less Fugly   Epicenter
73 Less Fugly Epicenter
 
Performance Tuning Web Apps - The Need For Speed
Performance Tuning Web Apps - The Need For SpeedPerformance Tuning Web Apps - The Need For Speed
Performance Tuning Web Apps - The Need For Speed
 
Boosting your conversion rate through web performance improvements
Boosting your conversion rate through web performance improvementsBoosting your conversion rate through web performance improvements
Boosting your conversion rate through web performance improvements
 
Responsive Web Design - Why and How
Responsive Web Design - Why and HowResponsive Web Design - Why and How
Responsive Web Design - Why and How
 
Beyond the Desktop: Sites and Apps for Phones and Tablets
Beyond the Desktop: Sites and Apps for Phones and TabletsBeyond the Desktop: Sites and Apps for Phones and Tablets
Beyond the Desktop: Sites and Apps for Phones and Tablets
 

Recently uploaded

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 

Recently uploaded (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 

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
  • 5.
  • 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