SlideShare a Scribd company logo
What is responsive?
And do I need it?
Carsten Sandtner  IPC 2015  @casarock
Carsten
Sandtner
Head of Development
@mediaman GmbH
Web Developer since 1998
@casarock
History!
https://flic.kr/p/9iMKjU
First responsive
Webpage!
The first website!
Print Design!
https://flic.kr/p/8xbEBF
Design for one resolution
Bring print to the web (1:1)
Pixelperfect
What is responsive - and do I need it?
dummy.gif
Floating boxes
https://flic.kr/p/4MFRpB
Finally a solution?
„depends“
=>
https://css-tricks.com/all-about-floats/
1994
Media Queries
HåkonWiumLie
1997
Media Queries: HTML4
considers to include them
2001
Media Queries:
Working draft
mobile
„revolution“
2008
2010
Responsive Web Design
EricMarcotte//Photoby:MartinKraft[CCBY-SA3.0]
http://alistapart.com/article/responsive-web-design
Combination of:
media queries
flexible widths
flexible images
RWD
2010
2012
Media Queries: W3C
Recommendation
Flexbox
https://flic.kr/p/nnnhq3
„The CSS3 Flexible Box, or flexbox, is a
layout mode providing for the
arrangement of elements on a page
such that the elements behave
predictably when the page layout must
accommodate different screen sizes
and different display devices.“
MDN: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexible_boxes
display: box;
~2009
Flexbox (first version)
display: flexbox;
~2011
Flexbox (second version)
display: flex;
> 2011
Flexbox (specification!)
RWD - in a nutshell
https://flic.kr/p/bYxKaN
Liquid:
fluid layout
Adaptive:
pre-defined layout widths
media queries
Definitions
liquid vs. adaptive
Definitions
responsive
http://blog.froont.com/9-basic-principles-of-responsive-web-design/
Combination
„Optimal rendering across devices“Goal
https://flic.kr/p/anLcHu
https://www.youtube.com/watch?v=SpRBvtm_wrQ
What could possibly go
wrong?
Image Sizes
too Big
Megabytes of data!
Even for mobile.
Images look a little fuzzy in high
resolutions.
Image Sizes
too small
Solution?
<img src="fallback.jpg"
srcset="small.jpg 640w 1x,
small-hd.jpg 640w 2x,
large.jpg 1x,
large-hd.jpg 2x"
alt="…">
HTML/CSS
srcset
<picture alt="description">
<source src="small.jpg">
<source src="medium.jpg"
media="(min-width: 40em)">
<source src="large.jpg"
media="(min-width: 80em)">
</picture>
HTML/CSS
picture
Support…
Browser Support
srcset vs. picture
http://caniuse.com
Meanwhile
https://flic.kr/p/fqofd6
Deliver same Content
Why?!
Content
Mobile users want compact content
Why should I deliver hidden
content then?
Content
same same but different
Rearrange Content on different
View Ports?
Content
structure
.some-element {
display: flex;
flex-direction: row;
order: 1;
}
Flexbox FTW!
Browser Support
flexbox
http://caniuse.com
Why load and parse unused
Javascripts and CSS?
Content
Javascripts/CSS
<!DOCTYPE HTML>
<html lang="en-US">
<head>
…
<link rel=“stylesheet" media=“screen
and (min-width: 600px)"
href=“small.css">
<link rel=“stylesheet" media=“screen
and (min-width: 2048px)“
href=“biggest.css">
…
</head>
<body>
…
</body>
</html>
Conditional loading?
CSS
What is responsive - and do I need it?
Back to …
https://flic.kr/p/fqofd6
Don’t even think about parallax…
Don’t even think about parallax on
mobile!
Effects
Javascript
https://flic.kr/p/cvvPLq
<script>
if (document.documentElement.clientWidth > 640) {
document.write('<script src="//ads.com/banner.js"></script>');
document.write('<script src="livechat.js"></script>');
}
</script>
Conditional loading?
<script data-mq="(min-width: 640px)"
data-src="//ads.com/banner.js"></script>
<script data-mq="(min-width: 640px)"
data-src="livechat.js" ></script>
<script>
var scripts = document.getElementsByTagName("script");
for(var i=0;i<scripts.length; i++) {
// Test if the Media Query matches
var mq = scripts[i].getAttribute("data-mq");
if (mq && window.matchMedia(mq).matches) {
// If so, append the new (async) element.
var s = document.createElement("script");
s.type = 'text/javascript';
s.src = scripts[i].getAttribute("data-src");
document.body.appendChild(s);
}
}
</script>
Better
Conditional loading?
https://www.safaribooksonline.com/library/view/responsive-fast/9781491912935/ch04.html
Desktop vs. mobile
https://flic.kr/p/bmJtgf
Mobile first?
Use Case!
Consider
Same content across devices?
Page with a lot of visuals?
Target group?
Target screen size?
Content rich sites
m.domains?
Pro
lightweight
mobile optimized
Con
SEO
„One URL per Page“
redirects
m.domain
Should I….
Client site feature
detection
https://flic.kr/p/ac3oaX
Feature detection
Conditional loading helpers
Modernizr
features
<script>
if (Modernizr.webgl){
doFancyStuff();
} else {
doSlowFancyStuff();
}
</script>
Feature
detection
<script>
Modernizr.load({
test: Modernizr.geolocation,
yep : ['geo.js', 'superfancy.css']
nope: 'geo-polyfill.js'
});
</script>
Conditional
loading
It helps a lot, but you still detect
everything at your clients browser!
Modernizr
Swiss army knife?
RWD starts at your Server
https://flic.kr/p/ac3oaX
Device-Description-Repository
Image optimization
Preprocessing HTML
Server
Viewport
Interaction model (touch?)
Hardware (Sensors)
Device-Description-
Repository
more than screen sizes…
Some Images are
scaleable
some not
Don’t load more than you’re going to show!
Image optimization
Why?
„optimized“ HTML across Screens
Less logic, less Javascript!
Hidden content not necessary
Preprocessing HTML
Serversite rendering
https://flic.kr/p/ac3oaX
reloaded!
Pro
less bloated HTML
only needed scripts will get loaded
Contra
higher server load
device detection is not reliable!
Server-Site Rendering
Best of both
https://flic.kr/p/69ZiLn
Responsive Design +
Server Side Components
1. Get a DDR
2. Write Server-Side Code using
DDR (e.g. conditional loading
etc.)
3. Enhance rendered HTML on
Client-Side
RESS
In a nutshell
1. Get a DDR
2. Detect features on Client-
Side
3. Write Server-Side Code using
DDR (e.g. conditional loading
etc.)
4. Set Cookies, reload.
RESS
In a nutshell
Websites should be loaded FAST
Websites should have a nice UX
Content should be optimized!
Content should be meaningful!
Why such a hassle?
Conclusion
https://flic.kr/p/7Cv2gu
Know your use case
Involve your server
RWD is NOT the holy grail!
sometimes a mobile site makes sense
Don’t forget the user!
Conclusion
Links
https://bradfrost.github.io/this-is-responsive/
http://www.liquidapsive.com/
http://alistapart.com/article/responsive-web-design
https://www.youtube.com/watch?v=XhCXINNvmv8
http://modernizr.com/
Questions?
https://flic.kr/p/qTw4b4
Contact me:
@casarock
hallo@appsbu.de

More Related Content

What is responsive - and do I need it?