going fast on the mobile web

59
Going Fast on the Mobile Web Work: http://cloudfour.com • Blog: http://userfirstweb.com • Twitter: @grigs Mobile Concurrency Test: http://cloudfour.com/mobile/ Flickr: Uploaded February 11, 2007 by hawridger by Jason Grigsby

Upload: jason-grigsby

Post on 28-Jan-2015

110 views

Category:

Technology


1 download

DESCRIPTION

Web Visions presentation on developing fast-loading web pages for mobile devices.

TRANSCRIPT

Page 1: Going Fast on the Mobile Web

Going Fast on the Mobile Web

Work: http://cloudfour.com • Blog: http://userfirstweb.com • Twitter: @grigs Mobile Concurrency Test: http://cloudfour.com/mobile/

Flickr: Uploaded February 11, 2007 by hawridger

by Jason Grigsby

Page 2: Going Fast on the Mobile Web

The Mobile Web is Coming.Web Developers aren’t Ready.

Flickr photo by look4u: http://www.flickr.com/photos/look4u/279668622/

Page 3: Going Fast on the Mobile Web

3.3BillionMobile phone for half the planet.

Flickr photo by Pingnews: http://www.flickr.com/photos/pingnews/370061022/

Page 5: Going Fast on the Mobile Web

2007 SMS Revenue: 100 billion

•Box Office•DVD Sales & Rentals•Music Industry•Video Games

CombinedFlickr photo by Vlastula: http://www.flickr.com/photos/vlastula/450642954/

Page 6: Going Fast on the Mobile Web

Flickr photo by CaptPiper: http://www.flickr.com/photos/piper/197153406/

Mobile is the Technology that Cried Wolf.(for 15 years)

Page 7: Going Fast on the Mobile Web

“The Mother of all Markets.”

Dr. Eli Harai, San Disk CEO, 2008

John Sculley, Apple CEO, 1992

http://query.nytimes.com/gst/fullpage.html?res=9E0CE5D9143AF93AA25754C0A964958260

Page 8: Going Fast on the Mobile Web

U.S. is behind in Mobile Technology(A.K.A. Why people got hung up on Japanese use of mobile phones to read books during Lynne D Johnson’s Keynote yesterday)

• Penetration Rates: Leaders: > 140% (Italy, S. Korea); US: 80%

• Networks: 3G launched in 2001 in Japan & S. Korea

• Handsets: iPhone not seen considered as innovative in other countries where they’ve had advanced phones for some time. Poorer countries willing to pay more for advanced handsets.

• Services: SMS per day per subscriber: S. Korea 10, Singapore 12, Philippines 15, U.S. 2.

Page 9: Going Fast on the Mobile Web
Page 10: Going Fast on the Mobile Web

Gopher, Mosaic, WAP, iPhone

Flickr photo by: http://www.flickr.com/photos/vixon/352427852/

Page 11: Going Fast on the Mobile Web

Gopher, Mosaic, WAP, iPhone

Flickr photo by: http://www.flickr.com/photos/vixon/352427852/

Page 12: Going Fast on the Mobile Web

Gopher, Mosaic, WAP, iPhone

Flickr photo by: http://www.flickr.com/photos/vixon/352427852/

Page 13: Going Fast on the Mobile Web

Gopher, Mosaic, WAP, iPhone

Flickr photo by: http://www.flickr.com/photos/vixon/352427852/

Page 14: Going Fast on the Mobile Web

8%4%

23%

65%

iPhone + iPod WinCE Symbian Hiptop

January 2008 Mobile Browser Stats

Source: www.netapplications.com

Page 15: Going Fast on the Mobile Web

“It’s about usage. Not units”

• Number of queries on Google search from iPhones surpassed those from Symbian-based phones in the days after Christmas. Nokia’s Symbian-based phones are 40% of the market worldwide.

• German iPhone users consume 30 times more data.

• 95% of iPhone customers regularly surf the Internet. Data services revenue increased from $2.7 billion in 2005 to $6.9 billion in 2007.

• Google sees 50 times the number of searches using the iPhone than any other mobile device. They were so surprised, they asked their engineers to check the logs to make sure it was correct.

• This is why major companies, Google, Quicken, etc. are all launching iPhone-optimized services despite the iPhone’s 1% market share.

Page 16: Going Fast on the Mobile Web

Why We’re Not Ready to Ride the

Mobile Wave

Flickr photo by .Hessam: http://www.flickr.com/photos/essamo/1070527547/

Page 17: Going Fast on the Mobile Web

1997

447 pages

1996

258 pages

1996

235 pages

1997

238 pages

1997

235 pages

Page 18: Going Fast on the Mobile Web

Flickr photo by mfajardo: http://www.flickr.com/photos/mfajardo/396104047/

We’ve Left Optimization Behind

Page 19: Going Fast on the Mobile Web

We’ve Become Bandwidth Gluttons

Since 2003:

• Web Page Size Tripled• # of Objects Doubled

Since 1995:

• Web Page Size: 22x• # of Objects: 21x

Source: http://www.websiteoptimization.com/speed/tweak/average-web-page/

Page 20: Going Fast on the Mobile Web

Flickr: Uploaded November 13, 2003 by Wools

2003: Business Critical Look at Speed

•Customer complaints•Limits of our 3 T-1s near•Months away from new data center

Page 21: Going Fast on the Mobile Web

0

15

30

45

60

Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

GBs of Data Transfer

Page 22: Going Fast on the Mobile Web

Flickr: Uploaded August 2, 2006 by pbo31

75% faster page loads 7 months in data center

Page 23: Going Fast on the Mobile Web

0.1 seconds — Viewed as Instantaneous1.0 seconds — Moving Freely10 seconds — Retain Focus on Task

Optimizing for Flow

Flickr: Uploaded August 7, 2007 by .Hessam

Page 24: Going Fast on the Mobile Web

Web Speed = Perception

UsabilityQuality

ServiceCredib

ility

Flickr: Uploaded October 15, 2006 by mattlogelin

Page 25: Going Fast on the Mobile Web

Yahoo!’s 80/20 Rule

Source: http://yuiblog.com/blog/2006/11/28/performance-research-part-1/

Page 26: Going Fast on the Mobile Web

Yahoo!’s 13 Performance Rules (Now 34!)

1. Make Fewer HTTP Requests

2. Use a Content Delivery Network

3. Add an Expires Header

4. Gzip Components

5. Put Stylesheets at the Top

6. Move Scripts to the Bottom

7. Avoid CSS Expressions

8. Make JavaScript and CSS External

9. Reduce DNS Lookups

10.Minify JavaScript

11.Avoid Redirects

12.Remove Duplicate Scripts

13.Configure ETags

Source: http://developer.yahoo.com/performance/rules.html

Page 27: Going Fast on the Mobile Web

GZIP Compression• If you do nothing else, DO THIS!

• GZIP can reduce files and download time up to 75%.

• Works on HTML, CSS, Javascript, XML and JSON files

• Most browsers handle GZIP correctly and the libraries like mod_gzip handle exceptions correctly.

Flickr: Uploaded February 11, 2007 by hawridger

Page 28: Going Fast on the Mobile Web

GZIP Case Study from Our 2003 Efforts

Version HTML CSS JS Total

Original 40,837 bytes

17,764 bytes

1,443 bytes

60,044bytes

Optimized 24,907bytes

5,320 bytes

1,443 bytes

31,670 bytes

GZIP 5,722bytes

5,320bytes

1,443bytes*

12,485bytes

Nearly 80% reduction in file size.

Page 29: Going Fast on the Mobile Web

Fewer HTTP Requests

Most browsers only open 2 http connections to one domain at a time.

Flickr: Uploaded April 28, 2007 by ((IANB))

Page 30: Going Fast on the Mobile Web

Parallel HTTP Requests

One Domain

Source: http://yuiblog.com/blog/2007/04/11/performance-research-part-4

Two Domains

Page 31: Going Fast on the Mobile Web

How do these rules apply to the mobile web?

Page 32: Going Fast on the Mobile Web

Numerous Mobile Browsers: Little Documentation

• Access

• Access Netfront

• BlackBerry

• IE Mobile

• Motorola Internet Browser

• Nokia

• Openwave Mobile Browser

• Opera Mini

• Opera Mobile

• Palm

• Safari

• Samsung

• Teleca-Obigo

• WinWAP

Source: http://wurfl.sourceforge.net/

No information on gzip support or # of concurrent connections.

Page 33: Going Fast on the Mobile Web

Cloud Four’s Mobile Browser Test

• Tests for number of concurrent connections and multiple domains.

• Looks for GZIP support.

• Looks for caching support.

• Works in any browser (even desktop):

• No javascript

• XHTML-MP

• http://www.cloudfour.com/mobile/ or simple text MOBILETEST to 41411.

Page 34: Going Fast on the Mobile Web

Cloud Four’s Mobile Browser Test

• Tests for number of concurrent connections and multiple domains.

• Looks for GZIP support.

• Looks for caching support.

• Works in any browser (even desktop):

• No javascript

• XHTML-MP

• http://www.cloudfour.com/mobile/ or simple text MOBILETEST to 41411.

Page 35: Going Fast on the Mobile Web

How Does the Test Work?

• Generates a unique token for this test

• Records selected HTTP headers for later analysis

• Computes the finish time (microsecond granularity) for the test, based on the current time and our desired delay factor

• Creates a database record for the test, containing: the token, start time, finish time, and zeroed counters for four separate domains

• Generates and delivers the test page containing 64 small (4x4 px) image requests evenly distributed across four separate domains

• Waits for the browser to fetch all images and render the page

deliver test pageto device under test

request imagesfrom server(s)

deliver delayed images

render testpage for user

t-zero t-finish(15 seconds)

(Server)

(Device)

request remaining

images

start test

deliver remainingimages

{ delay until timeout }

Page 36: Going Fast on the Mobile Web

Initial Results — Still Looking for More Testers

•Over 1,300 tests

•448 Unique User Agents

•169 Unique Mobile User Agents

•Fun items like Kindle, PS3, Zune.

17%

83%

GZIPNo GZIP

32%

68%

CachingNo Caching

Page 37: Going Fast on the Mobile Web

Browser GZIP Caching Domain1 Domain 2 Domain 3 Domain 4Total

Connections

Blackberry Browser 20% 71% 4 0 0 0 4

IE Mobile 6.x 83% 100% 3 0 0 0 3

IE Mobile 7.x 100% 89% 3 0 0 0 3

Opera Mini 3.x 100% 100% 10 10 10 10 40

Opera Mini 4.x 100% 0% 2 1 1 1 5

Opera Mobile 8.x 86% 89% 2 2 2 2 8

Safari (iPhone/iPod) 100% 100% 4 4 4 4 16

Symbian (WebKit) 100% 100% 7 0 0 0 7

Major Mobile Browsers

Page 38: Going Fast on the Mobile Web

Browser GZIP Caching Domain1 Domain 2 Domain 3 Domain 4Total

Connections

Danger Hiptop 0% ? 3 0 0 0 3

Jataayu 100% 0% 10 0 0 0 10

NetFront 3.x 87% 100% 1 to 4 0 0 0 1 to 4

Nokia Browser 100% 100% 1 to 7 0 to 5 0 to 1 0 to 1 4 to 12

Obigo 0% 0% 3 0 0 0 3

Open Wave Mobile 6.2 100% 0% 4 0 0 0 4

Palm Blazer 71% 50% 4 0 0 0 4

SEMC Browser 100% ? 2 2 2 2 8

UP.Browser 50% 100% 1 to 4 0 0 0 1 to 4

Zune 100% 100% 16 16 16 16 64

Other Mobile Browsers

Page 39: Going Fast on the Mobile Web

Preliminary Conclusions from Our Tests

• GZIP support is much better than we anticipated.

• Caching support is much less than we anticipated.

• Full 3G speeds will only come for Windows Mobile and Blackberries after they address their browser deficiencies (concurrent connections, rendering engines and processor speed).

• Lots of variability between browsers means necessary testing.

• Still much to learn about mobile browser performance

Page 40: Going Fast on the Mobile Web

Other Mobile Browser Characteristics

• Two sites that help you understand mobile device properties:

• WURFL: http://wurfl.sourceforge.net/

• Device Atlas: http://www.deviceatlas.com/

• Our concurrency test to be included in the DeviceAtlas database.

• Also published under creative commons.

Page 41: Going Fast on the Mobile Web

Eight Recommendations for All Mobile Devices

1. Turn on GZIP Compression

2. Fewer Files

3. Aggressively Encourage Caching

4. Minimize File Sizes

5. Simple, Valid Markup

6. Reduce DNS Lookups

7. Avoid Redirects

8. Limit Cookies

Likely benefit from all 34 Yahoo! guidelines.http://developer.yahoo.com/performance/rules.html

Page 43: Going Fast on the Mobile Web

Flickr photo by mkw87: http://www.flickr.com/photo_zoom.gne?id=437942494&size=l

2. Fewer Files•HTTP Connections are expensive

•No more than 1 external CSS & 1 external JS

•Consider embedding CSS & JS unless you are confident about your caching.

•Remove any unnecessary files (print css)

•If CSS is supported, use CSS sprites.

•Consider inline images using data url

Page 44: Going Fast on the Mobile Web

Flickr photo by mkw87: http://www.flickr.com/photo_zoom.gne?id=437942494&size=l

2. Fewer Files: Inline Images

<img src="data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/f3//Ub//ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj/gAwXEQA7" width="16" height="14" alt="embedded folder icon" />

background:url(data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/f3//Ub//ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj/gAwXEQA7) top left no-repeat; )

Test extensively. Not supported in all browsers.

Page 45: Going Fast on the Mobile Web

Flickr photo by John Wardell (Netinho): http://www.flickr.com/photo_zoom.gne?id=760902403&size=l

3. Aggressively Encourage Caching

•Goal #1: No HTTP HEAD Requests.

•Add Expires header. Put it far into the future.

•Develop naming conventions for versioning of files. Update filename when file is modified.

e.g., logo080523.png

•Keep files under 25k for mobile devices.

•Configure or remove ETags from files.

•Watch your logs to make sure caching works.

Page 46: Going Fast on the Mobile Web

4. Minimize File Sizes

•Three reasons why file size matters:

•Download time

•Caching

•Memory

•Minimize all html, css, & javascript regardless of GZIP.

•Squeeze all unnecessary data out of images.

Flickr photo by Amodiovalerio Verde: http://www.flickr.com/photo_zoom.gne?id=425333516&size=o

Remember every bit counts!

Page 47: Going Fast on the Mobile Web

Jason Grigsby • http://userfirstweb.comSeptember 19 • DevGroup NW

• CSS-based vs. table layoutsTables are complex to render.

• Separate content, style, behavior

• Less markup overall

• ESPN proved that this change can be significant alone.

• Consider processing time to determine layout in addition to download time.

Flickr photo by bertheymans: http://www.flickr.com/photo_zoom.gne?id=337851288&size=l

5. Simple, Valid Markup

Page 48: Going Fast on the Mobile Web

Jason Grigsby • http://userfirstweb.comSeptember 19 • DevGroup NW

• Each DNS lookup costs performance. No control over the DNS speed.

• Nothing can be downloaded from the domain until the lookup completes.

• Optimum is between 2 and no more than 4 domains per web page because of concurrent download benefits.

Flickr photo by André-Batista: http://www.flickr.com/photo_zoom.gne?id=408700622&size=o

6. Reduce DNS Lookups

Page 49: Going Fast on the Mobile Web

Flickr photo by (nz) dave: http://www.flickr.com/photo_zoom.gne?id=245728298&size=l

7. Avoid Redirects

•Redirects cost the user time so avoid the easy ones. Particularly painful for mobile.

•Permanent 301 redirects should be modified to be cacheable (expires header)

•Put the trailing slash on your links and shave time off of Apache doing the work.

Page 50: Going Fast on the Mobile Web

8. Limit Cookies

• Cookies uploaded with every request! Upload rates are much slower than download speeds.

• Goal: Zero or One Cookie. Diet time!

• Make the cookie as small as possible. Track details on the server side.

• Use www or other sub-domain and restrict cookies to that domain.

• Move images, css, javascript to another domain where cookies will not be used.

Page 51: Going Fast on the Mobile Web

Eight Recommendations for Post iPhone Devices

1.Optimize javascript performance

2.Reduce DOM elements

3.Javascript at bottom of page

4.CSS in the head tag

5.Lazy Load Components

6.Use GET unless you need POST

7.Use JSON instead of XML

8.Use hardware accelerated effects

Page 52: Going Fast on the Mobile Web

YSlow Firebug Pluginhttp://developer.yahoo.com/yslow/

Page 53: Going Fast on the Mobile Web

Safari Web Inspector

Page 54: Going Fast on the Mobile Web

User Agent Switcherhttp://chrispederick.com/work/user-agent-switcher/http://dev.mobi/blog/user-agent-switcher-config-file

Page 55: Going Fast on the Mobile Web

Test Your Work!

Page 56: Going Fast on the Mobile Web
Page 57: Going Fast on the Mobile Web

Flickr photo by MarkKelley: http://www.flickr.com/photos/markkelley/1022720488/

Page 58: Going Fast on the Mobile Web

Embrace the constraints

Make optimization

a game

Flickr photo by localsurfer: http://www.flickr.com/photos/localsurfer/180834588/

Page 59: Going Fast on the Mobile Web

Thank You for Your Time

Mobile Portland

Meets on 4th Monday

Next Meeting Tuesday(!)May 27th, 6 pm

Join us at our next meetingor Google Group.

http://mobileportland.com

Work: http://cloudfour.com • Blog: http://userfirstweb.com • Twitter: @grigs Mobile Concurrency Test: http://cloudfour.com/mobile/