new frontier of responsive & device-friendly web...

24
New frontier of responsive & device-friendly web sites Dino Esposito JetBrains dino.esposito@jetbrains.com @despos facebook.com/naa4e

Upload: others

Post on 27-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

New frontier of responsive &

device-friendly web sites

Dino Esposito

JetBrains

[email protected]

@despos

facebook.com/naa4e

Page 2: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

Responsive Web Design

Page 3: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

Why Do You Do RWD?

Can I Ask You a Question?

Page 4: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

How Much Do You Care About DEVICES?

Page 5: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

RWD ignores devices!

Can I Share a Secret With You?

RWD just cares about screen width.

And screen width analysis is subject to false positives!Let me give it a try…

Page 6: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

Typically…

Detecting devices is hard?

Don’t do that. Be smart and let the

browser do the job.

Through CSS.

Page 7: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

RWD at a Glance…

Page 8: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

Same content downloaded to just any user agents

No distinction whatsoever

Regardless of the requesting URL

Regardless of the requesting user agent string

Regardless of the hosting platform

Regardless of the actual capabilities of the requesting device

Once the content is on the client …

Page 9: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

What CSS Can Do For You

Reposition HTML

elementsPlaying with relative and

absolute positioning

Playing with the floatattribute

Width of containers as a

percentage of the parent’s width

Bounce content that exceed horizontal

boundaries

Omit height to enable vertical

scrolling

Show/Hide elements

Page 10: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

What CSS Can’t Do for You

Switch to different layouts

Without serving the content for all

possible layouts and then hiding those that don’t apply

Support different experiences and

use-cases

CSS works on top of the SAME view

Renders the SAME view differently

Can’t serve device-specific views

Can’t optimize markup and images

Can’t minimize requests

Can’t change graphics on iOS and

Android smartphones

Page 11: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

• Conditional CSS style sheets

• http://www.w3.org/TR/css3-mediaqueries

• Newer draft in the works

CSS Media Queries

Page 12: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

<link type="text/css" rel="stylesheet" href="view480.css"media="only screen and (max-width: 480px)">

<link type="text/css" rel="stylesheet" href="view800.css"media="only screen and (max-width: 800px)">

Page 13: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

view480.css

400px

Same amount of content

view480.css

400px

Powerful laptop, wifi Smartphone, 3G

Browser

Page 14: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

RWD Core Issues

Images Use-cases

Page 15: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

<picture alt=""><source media="(min-width: 992px)" srcset="large-1.jpg 1x, large-2.jpg 2x"><source media="(min-width: 640px)" srcset="med-1.jpg 1x, med-2.jpg 2x"><source srcset="small-1.jpg 1x, small-2.jpg 2x"> <img src="small-1.jpg">

</picture>

Pixel density for

high resolution displays

Page 16: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

Choose a thumbnail

Page 17: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

WURFL Image Tailor (WIT)

Server-side tool acting as a proxy

• Detect device and resize given image appropriately

• Can crop and resize to given dimensions

WIT vs. PICTURE

• WIT is available today: http://web.wurfl.io (free)

• WIT lets you focus on a single image

• Treats smartphones differently from resized browsers

<img src="//wit.wurfl.io/http://www.yoursite.com/images/img.jpg">

Page 18: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

WURFL.JS

Device information injected in your code• Real device detection out-of-the-box

Get to know• Form-factor: smartphone, tablet, desktop, Xbox

• Operating system: iOS, Android

Page 19: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

DEMOhttp://web.wurfl.io

Page 20: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

• Classes of

devices

• Detection

framework

• Adaptive

rendering

Goal: best experience on the device

Page 21: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

HTTP module

static void OnBeginRequest(Object sender, EventArgs e){

var app = sender as HttpApplication;if (app == null)

throw new ArgumentNullException("sender");

var isMobileDevice = IsMobileRequest(app);

// More ...:

}

Page 22: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

How do you detect mobile devices?

Page 23: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

Device Detection

SERVER

Regex for substrings

WURFL API

Cloud

On-premise

Page 24: New frontier of responsive & device-friendly web sitessddconf.com/.../library/New_Frontier_Of_Responsive_Sites.pdf · 2015-05-05 · What CSS Can’t Do for You Switch to different

FOLLOW

That’s All Folks!

facebook.com/naa4e

software2cents.wordpress.com

[email protected]

@despos