don't touch the mobile parts

46
Don't touch the mobile parts Francesco Fullone <[email protected]> Twitter @fullo

Upload: francesco-fullone

Post on 14-Jan-2015

1.874 views

Category:

Technology


1 download

DESCRIPTION

Building website is an hard task, optimize it for a desktop browser is not trivial. What happen when we have to optimize it for a mobile browser?

TRANSCRIPT

Page 1: Don't touch the mobile parts

Don't touch the mobile partsFrancesco Fullone <[email protected]> Twitter @fullo

Page 2: Don't touch the mobile parts

Who am I

Francesco Fullone aka Fullo

- PHP developer since 1999

- President

- and Open Source Evangelist

- CEO @

- founder @

- Nerd and geek

Page 3: Don't touch the mobile parts

In the previous* WPO episodes

* “don't touch the slow parts ” [ http://ow.ly/5ihyb ] and “extended slow parts” [ http://ow.ly/5ihLT ]

Page 4: Don't touch the mobile parts

Kate and Jack discovered that the 80% of loading time

is on the browser

Page 5: Don't touch the mobile parts

In the same time Lockeunderstood that

resource loading order matters

Page 6: Don't touch the mobile parts

Sayid tried to cut the bandwidth usage

decreasing files number and size...

Page 7: Don't touch the mobile parts

… helped by Hurley whomreduces downloads forcing

headers to enable browser cache

Page 8: Don't touch the mobile parts

at the same time, the “Others” studied the new possibilities offered by the

HTML5

Page 9: Don't touch the mobile parts

They never believe thatmobile WPO is an even more

mysterious and frightening journey...

Page 10: Don't touch the mobile parts

...and that 97% of performance issues happen at frontend*

* from webperformancetoday.com [ http://ow.ly/5hd35 ]

Page 11: Don't touch the mobile parts

The Browser Chapter

Page 12: Don't touch the mobile parts

On a smartphone a web pageis rendered from 40% to 80% slower

than on a desktop.

Page 13: Don't touch the mobile parts

A lot of different browsers

Pre-installed webkit(iOS, Android, Blackberry, webOS, Symbian …)

Pre-installed non-webkit(Bada, old Blackberry, Internet Explorer, DoCoMo …)

User installable(Opera Mobile/Mini, Firefox, Skyfire ...)

Page 14: Don't touch the mobile parts

Same engine doesn't meansame behaviours

Page 15: Don't touch the mobile parts

We have to talk about mobile browser families:

SmartphoneMid-EndLow-End

Page 16: Don't touch the mobile parts

Mid-End to Low-End browsers families lost (randomly):

HTML5 supportCSS3 support

Caching quotaAjax

Page 17: Don't touch the mobile parts

Still...

Page 18: Don't touch the mobile parts

Symbian's Anna WebKit browser* has

No Application CacheNo Geolocalization APINo HTML5 Audio/Video tagsVery limited CSS3 support

* Released on April 2011 for X7 and E6 Nokia Smartphones

Page 19: Don't touch the mobile parts

CSS Expressions and iFrames don't work on most mobile browsers

Page 20: Don't touch the mobile parts

Different country* means different browser

* From icrossing.co.uk [ http://ow.ly/5hanY ]

Page 21: Don't touch the mobile parts

Caching, now, is not a difficult task

* browserscope.org helps us [ http://ow.ly/5h8Db ]

Page 22: Don't touch the mobile parts

New iOS* and Android browsers have

4Mb file cache (uncompressed)4Mb total cache (uncompressed)1Mb limit for file execution (js/css)

* but cache is invalidated at the reboot [ http://ow.ly/5h8G4 ]

Page 23: Don't touch the mobile parts

But...

Page 24: Don't touch the mobile parts

Old iOS 3.x browser* had

25.6Kb file cache1Mb total cache (uncompressed)

* and a lot of other low-end browsers

Page 25: Don't touch the mobile parts

The Network Chapter

Page 26: Don't touch the mobile parts

3G Networks are slow, with higher latency and limited*

* comet doesn't works and 3G operator applies some limits.

Page 27: Don't touch the mobile parts

HTTP Headers are different*[...]

user-agent: LG-CU920/V1.0p Obigo/Q05A Profile/MIDP-2.0 Configuration/CLDC-1.1via: 1.1 alpmagr1fe02WAP2-mbl

x-up-devcap-accept-language: en,fr,esx-up-devcap-charset: US-ASCII,ISO-8859-1,UTF-8,UTF-16,ISO-8859-15,ISO-10646-UCS-2

x-up-devcap-iscolor: 1x-up-devcap-numsoftkeys: 3x-up-devcap-screendepth: 16

x-up-devcap-screenpixels: 240,400x-up-devcap-smartdialing: 1

x-up-subno: ppu_1077a8d8fc1_vmag.mycingular.netx-wap-profile: http://gsm.lge.com/html/gsm/LG-CU920.xml

[...]

* 30% more than desktop, ETag doesn't works

Page 28: Don't touch the mobile parts

Beware of the content proxies*!

* used by some browsers like Opera mini. Ajax doesn't work properly

Page 29: Don't touch the mobile parts

The Mobile WPO Chapter

Page 30: Don't touch the mobile parts

As for desktop browsers a reduction of the requests is necessary,

but mobile strategies are somewhat differents

Page 31: Don't touch the mobile parts

When possible embed resources in the page: CSS, JavaScript* and images

with data URI

* then save them after document.onload in local cache

Page 32: Don't touch the mobile parts

Use Application Storage to statically save most used resources and user

infos* in localStorage

* as the geolocation infos and prefs

Page 33: Don't touch the mobile parts

Save JavaScript function with Application Storage*, then fire them

to a tag and eval when needed

* as Google and Bing do [ http://ow.ly/5h8Ab ]

Page 34: Don't touch the mobile parts

Load resources as late as possible* and store them to be never loaded

again

* use ajax and infinite scrolling pattern [ http://ow.ly/5h9A6 ] to load only visible data, but remember to free memory

Page 35: Don't touch the mobile parts

Use CSS to draw interface object*-webkit-border-image, CSS sprites, -webkit-border-

radius, -webkit-gradient, ...

* but remember that the browsers compatibility changes

Page 36: Don't touch the mobile parts

Optimize images* and defer them when possible. Use SVG for charts.

* animated GIF doesn't work on Android and WebOS, SVG is not enabled on Android. When possible strip EXIF tags.

Page 37: Don't touch the mobile parts

GZip, Minify and Merge CSS and JavaScript*

* as usual ;)

Page 38: Don't touch the mobile parts

When possible avoid JavaScript frameworks*

and use specific ones (ie. zepto.js)

* some mobile browser can take up to 8s to parse jQuery

Page 39: Don't touch the mobile parts

Detect device, reduce image details as needed

* use window.devicePixelRatio on WebKit

Page 40: Don't touch the mobile parts

HTML coding still matter

Page 41: Don't touch the mobile parts

Use different (KiSS*) html than in the desktop browser

* reduce elements. You are still on a 3/4'' device, isn't it?

Page 42: Don't touch the mobile parts

Reduce DOM elements, CSS classes and apply good programming

patterns

Page 43: Don't touch the mobile parts

Add specificic html meta tags* for mobile browsers

* viewport, media=handheld, MobileOptimized, HandheldFriendly

* add the right MIME for each device and use viewport meta tag

Page 44: Don't touch the mobile parts

Test your code

http://mobile.httparchive.org

http://blaze.io/mobile

http://jdrop.org

http://www.mobilexweb.com

Page 45: Don't touch the mobile parts

Your new best friend*

* buy it on Amazon http://ow.ly/5sm6C

Page 46: Don't touch the mobile parts

via Quinto Bucci 20547023 Cesena (FC)

info AT makemeapp.itwww.makemeapp.it

Francesco [email protected]

@fullo