SlideShare ist ein Scribd-Unternehmen logo
1 von 69
Downloaden Sie, um offline zu lesen
RESS

RWD and Server Side Components
Sven Wolfermann | maddesigns
Sven Wolfermann (36)
· Freelancer for modern web development
(HTML5, CSS3, jQuery) from Berlin
· CSS3 Adventskalender 2010/2011
· wrotes articles and post for T3N-, PHP- and
Webstandards-Magazin (new: Screengui.de)
· mobile Geek

· Twitter: @maddesigns
· Web: http://maddesigns.de

/
www vs. m.

desktop vs mobile

/
desktop vs. mobile
dividing pages
large site (feature rich) vs. small size (performant)

/
desktop vs tablet vs mobile
dividing more pages?
large site vs. tablet vs. small size

vs. car vs. fridge vs. watch vs. …

/
Responsive Web Design

A List Apart article by Ethan Marcotte

/
A List Apart is responsive too now
Responsive Web Design
· Flexible grids, based on percentage units
· Variable image and video sizes – images fit into grid
· CSS3 media queries

image source: http://macrojuice.com/

/
RWD
solves many things
· one URL, one code base, one deployment
· all contents available (if not hidden)
· Future friendly

/
moto.oakley.com
·

· 85.4MB page weight
· 471 HTTP requests
· 2 minutes 45 seconds until loading screen replaced with
content
· 4 minutes 10 seconds until onLoad event
85.4MB, 471 HTTP requests!
THIS IS NOT RWD!

Oakley's monster page of baubles

/
moto.oakley.com fail
ok, ok, Oakley does it better now:
JUST 14.2MB, 291 request (more than 70MB less)

with mobile user-agent? 6.7MB, 114 requests :/

Oakley's Moto diet

/
RWD
has some issues
· site tend to be too large for mobile
· some content is hard to adapt: images, tables, ads, ...
· IE8 doesn't understand RWD (basically)

/
Guy Podjarny's RWD performance tests

sites have nearly same weight on mobile as on desktop
Real World RWD Performance – Take 2

/
RWD is more

Beyond Squishy: The Principles of Adaptive Design
Performance
· Reduce image payload (the biggest effect)
· Reduce JavaScript and CSS payload
· Further optimize based on feature detection

Lightening Your Responsive Website Design With RESS

/
Browser Feature Detection
/
Testing browser features with Vanilla JS
Cutting the mustard
if('querySelector' in document
&& 'localStorage' in window
&& 'addEventListener' in window) {
// bootstrap the javascript application
}

if browser supports
'querySelector',
'localStorage'
and 'addEventListener'
do hot stuff

BBC Responsive News – Cutting the mustard

/
Modernizr
Client side feature detection

Modernizr is a JavaScript library that detects HTML5 & CSS3 features in
the user's browser.
http://modernizr.com/
/
Modernizr
throw in <head>
<head>
<script src="modernizr.js"></script>
</head>

Modernizr features test: geolocation
Modernizr.geolocation // true or false

if (Modernizr.geolocation) {
navigator.geolocation.getCurrentPosition(show_map);
} else {
// no native support; maybe try a fallback?
}

/
Modernizr
Modernizr can load different files based on tests
Modernizr.load({
test: Modernizr.geolocation,
yep : 'geo.js',
nope: 'geo-polyfill.js'
});

Modernizr.load is not part of the "development" version
Modernizr adds classes to <html>
<html class="js flexbox canvas canvastext webgl no-touch geolocation
postmessage hashchange history boxshadow cssanimations csscolumns
cssgradients csstransforms csstransforms3d csstransitions fontface
video audio localstorage svg inlinesvg">

/
Modernizr
Another Sample: datepicker
<script src="modernizr.js"></script>
<script>
Modernizr.load({
test: Modernizr.inputtypes.date,
nope: ['jquery.datepicker.js', 'jquery.datepicker.css'],
complete: function () {
$('input[type=date]').datepicker({
dateFormat: 'yy-mm-dd'
});
}
});
</script>

load jQuery datepicker library for browsers that don't have native
datepickers
/
Conditional loading
/
Conditional loading

http://bradfrostweb.com/wp-content/uploads/2013/09/Keynote-11.png
Conditional loading

http://bradfrostweb.com/wp-content/uploads/2013/09/Keynote3.png
Conditional loading – window.matchMedia
Returns a new MediaQueryList object representing the parsed results
of the specified media query string.
if (window.matchMedia("(min-width: 40em)").matches) {
/* load secondary stuff */
}

matchMedia Polyfill
Modernizr.load and Picturefill uses matchMedia for example

MDN Window.matchMedia

/
Conditional loading – Modernizr.load
Modernizr loads scripts and CSS based on media queries
Modernizr.load([
{
test: Modernizr.mq("only screen and (min-width: 1051px)"),
yep: '/js/large.js'
},
{
test: Modernizr.mq("only screen and (min-width: 600px) and (max-width: 1050px)"),
yep: '/js/medium.js'
},
{
test: Modernizr.mq("only screen and (min-width: 320px) and (max-width: 599px)"),
yep: '/js/small.js'
}
]);

you can use EM in media queries too ;)
/
Conditional loading – pairing CSS & JS
holding CSS and JavaScript Breakpoints in sync
body:after {
content: 'small';
display: none;
}
@media (min-width: 650px) {
body:after {
content: 'middle';
}
}
@media (min-width: 1200px) {
body:after {
content: 'large';
}
}

/
Conditional loading – pairing CSS & JS
holding CSS and JavaScript Breakpoints in sync
var size = window.getComputedStyle(document.body,':after')
.getPropertyValue('content');

if (size == 'large') {
// Load some more content.
}

Conditional CSS

/
Conditional loading – Ajax-include pattern
Replace:
<a href="..." data-replace="latest/fragment">Latest Articles</a>

Before:
<a href="..." data-before="latest/fragment">Latest Articles</a>

After:
<a href="..." data-after="latest/fragment">Latest Articles</a>

init with jQuery:
$("[data-replace],[data-before],[data-after]").ajaxInclude();

An Ajax-Include Pattern for Modular Content

/
Browser-Sniffing
Browser-Sniffing
remember the old days? Not? You lucky guy!
UA-string history

Browser-Sniffing went wrong
/
Browser-Sniffing
is hard and unreliable
For example, Safari user agent string on an iOS7 iPhone:
Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X)
AppleWebKit/546.10 (KHTML, like Gecko) Version/6.0 Mobile/7E18WD
Safari/8536.25

often browsers aims other browsers
detecting the "right" user agent is complicated
Parsing UA string is not a regex job
UA-Detection libraries

/
What?! UA-Sniffing is wild guessing
This is NOT a "mobile" detection!
if((navigator.userAgent.match(/iPhone/i)) ||
(navigator.userAgent.match(/iPod/i))) {
if (document.cookie.indexOf("mobile_redirect=false") == -1) {
window.location = "http://m.yoursite.com/";
}
}

more like this
// Check if UA is mobile (from http://detectmobilebrowsers.com/)
if(/(android|bbd+|meego).+mobile|avantgo|bada/|blackberry
|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris
|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?
|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian
|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)
|xda|xiino/i.test(agent) {
isUAMobile = true;
}
/
Device Detection
/
Device Detection Libraries
· WURFL (Java/.NET/PHP) free *
· Scientiamobile (Java/.NET/PHP) commercial *
· Device Atlas (Java/.NET/PHP) commercial
· Netbiscuits' Device Library commercial
· 51degrees (.NET, C, Java, PHP) free limited / commercial
· Open DDR (Java/.net) Open Source
· Mobile Detect (PHP) Open Source

*

/

free with restricted license
Device Detection Libraries
Problems
· updates are slow
· not reliable

/
Client meets server
/
Client meets Server
set browser width cookie with JS
RESS = {};
RESS.writeCookie = function (name, value) { //cookie code }
//Store width in a cookie
RESS.storeSizes = function () {
//Get screen width
var width = window.innerWidth;
// Set a cookie with the client side capabilities.
RESS.writeCookie("RESS", "width." + width);
}
RESS.storeSizes();

/
Client meets Server
use cookie info in code
Setting a file path based on window.innerWidth
<?php
// grab the cookie value
$screenWidth = $_COOKIE['RESS'];
// set the img path var
if ($screenWidth <= 320) {
$imgPath = "320";
} else if ($screenWidth < 960) {
$imgPath = "640";
} else {
$imgPath = "960";
}
// print out our image link
print "<img src='/rwd/images/".$imgPath."/car.jpg' alt='Car' />";
?>
http://www.netmagazine.com/tutorials/getting-started-ress

/
Client meets Server
use cookie info in code
<?php
if ($RESS["width"] >= 320 && $RESS["width"] <= 640) {
?>
<div class="mobile-ad max-320">
<?php include "/ads/320.php"?>
</div>
<?php } ?>

/
Modernizr Server
Client features for the server
<?php
include('modernizr-server.php');
print 'The server knows:';
foreach($modernizr as $feature=>$value) {
print "
$feature: "; print_r($value);
}
?>
The server knows:
canvas: 1
geolocation: 1
crosswindowmessaging: 1
indexeddb: 0
hashchange: 1
...
https://github.com/jamesgpearce/modernizr-server

/
RESS

Responsive Web Design + Server Side Components

/
RESS

http://www.lukew.com/ff/entry.asp?1392

/
“ In a nutshell, RESS combines adaptive

layouts with server side component
(not full page) optimization. So a single
set of page templates define an entire
Web site for all devices but key
components within that site have
device-class specific implementations
that are rendered server side. ”

—Luke Wroblewski @lukew

http://www.lukew.com/ff/entry.asp?1392

/
Sapient Nitro about RESS

http://www.youtube.com/embed/XhCXINNvmv8

/
Advantages of RESS
· Easier to navigate: The navigation structure can be customized for the
different tasks.
· Less page bloat: Instead of relying on display: none; or visibility:
hidden; to hide page elements for mobile devices, removed from the
HTML or CSS.
· Faster load time: Unnecessary CSS/JavaScript can be removed from
the HTML

/
Disadvantages of RESS
· More server resources: Dynamically building the HTML will increase
the load on the server.
· Caching: A need for a better caching mechanism
· Requires device detection: Mobile users will need to be detected.
Device detection is unreliable.

/
RESS in the wild? -> Adaptive Images

http://adaptive-images.com/

/
Adaptive Images

/
Adaptive Images
· Add .htaccess and adaptive-images.php to your document-root
folder.
· Add one line of JavaScript into the <head> of your site.
· Add your CSS Media Query values into $resolutions in the PHP file.

/
Adaptive Images
1. The HTML starts to load in the browser and a snippet of JS in the <head> writes a
session cookie, storing the visitor's screen size in pixels.
2. The browser then encounters an <img> tag and sends a request to the server for that
image. It also sends the cookie, because that’s how browsers work.
3. Apache receives the request for the image and immediately has a look in the website's
.htaccess file, to see if there are any special instructions for serving files.
4. There are! The .htaccess says "Dear server, any request you get for a JPG, GIF, or
PNG file please send to the adaptive-images.php file instead."

/
Adaptive Images
5. The PHP file looks for a cookie and finds that the user has a maximum screen size of
480px.
6. It compares the cookie value with all $resolution sizes that were configured, and
decides which matches best. In this case, an image maxing out at 480px wide.
7. It then has a look inside the /ai-cache/480/ folder to see if a rescaled image already
exists.
8. We'll pretend it doesn’t - the PHP then goes to the actual requested URI to find the
original file.
9. It checks the image width. If that's smaller than the user's screen width it sends the
image.
10. If it's larger, the PHP creates a down-scaled copy and saves that into the
/ai-cache/480/ folder ready for the next time it's needed, and sends it to the user.

http://adaptive-images.com/

/
Responsive Images
a topic for itself…
Responsive Images [german]

/
Detector
/
Detector (PHP RESS library)
combines UA-parsing and feature testing
· includes User Agent parser – record any useful information (like OS or
device name)
· includes Modernizr Server
no need for commercial device detection libraries
add your own feature tests and store the results using Modernizr's
addTest() API

/
Detector
1.· HTTP request hits server
2.· Detector compares User-Agent with database
3.· if known, classify device and get back content
4.· if not, Modernizr makes feature detection, stores cookie
5.· reloads site, gives back specified content
6.· stores UA-String/features combination for later use

How Detector works

/
Detector device families
The default install of Detector will categorize browsers into one of three
families.
// families.json
{
"tablet": {
"isTablet": true
},
"mobile-advanced": {
"isMobile": true,
"features": ["cssanimations","localstorage","deviceorientation"]
},
"mobile-basic": {
"isMobile": true
},
"desktop": {
"isComputer": true
}
}
/
Detector sample
switch ads, basic sample
if ($ua->family == 'mobile-basic') {
include "/ads/simple.php";
} elseif ($ua->family == 'mobile-advanced') {
include "/ads/responsive-ads.php";
} else {
include "/ads/desktop.php";
}

Detector video sample
if ($ua->video->h264 || $ua->video->webm) {
print $html5Embed; // YouTube's <iframe> code
} else {
print $simpleLink;
}

/
RESS examples
University of Notre Dame
West Virginia University
CNN
Scientiamobile

/
RESS isn't the holy grail (RWD isn't either)
RESS – further reading
Templating with Detector & Mustache for RESS
Is Adaptive Web Design Or RESS Better Than Responsive Design For
SEO?
Adaptation: Why responsive design actually begins on the server

/
One more thing!
/
Client Hints
Client Hints is a new proposal by Ilja Grigorik and will allow clients to
indicate a list of device and agent specific preferences. Spec Draft
(request)
GET /img.jpg HTTP/1.1
User-Agent: Awesome Browser
Accept: image/webp, image/jpg
CH: dpr=2.0
(response)
HTTP/1.1 200 OK
Server: Awesome Server
Content-Type: image/jpg
Content-Length: 124523
Vary: CH
(image data)
Automating DPR switching with Client-Hints

/
Client Hints
For example, given the following request header:
CH: dh=598, dw=384, dpr=2.0

The server knows that the client's screen height is 598px, width is
384px, as measured by density independent pixels on the device, and
that the device pixel ratio is 2.0.

/
Client Hints
ReSrc.it can handle client hints now

/
Questions?

Thanks for your attention!
Sven Wolfermann | maddesigns
http://maddesigns.de/RESS/

HTML5 slideshow by Google

/

Weitere ähnliche Inhalte

Was ist angesagt?

Dynamic User Interfaces for Desktop and Mobile
Dynamic User Interfaces for Desktop and MobileDynamic User Interfaces for Desktop and Mobile
Dynamic User Interfaces for Desktop and Mobilepeychevi
 
Thats Not Flash?
Thats Not Flash?Thats Not Flash?
Thats Not Flash?Mike Wilcox
 
Node.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash CourseNode.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash CourseAaron Silverman
 
Building single page applications
Building single page applicationsBuilding single page applications
Building single page applicationsSC5.io
 
3D and VR on the web
3D and VR on the web3D and VR on the web
3D and VR on the webAdam Nagy
 
Web Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing CombinationWeb Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing CombinationAndrew Rota
 
Responsive Web in Brief
Responsive Web in BriefResponsive Web in Brief
Responsive Web in BriefEPAM
 
More Than You Ever Wanted to Know About Resource Hints - Harry Roberts (CSS W...
More Than You Ever Wanted to Know About Resource Hints - Harry Roberts (CSS W...More Than You Ever Wanted to Know About Resource Hints - Harry Roberts (CSS W...
More Than You Ever Wanted to Know About Resource Hints - Harry Roberts (CSS W...Shift Conference
 
HTML5 and CSS3: does now really mean now?
HTML5 and CSS3: does now really mean now?HTML5 and CSS3: does now really mean now?
HTML5 and CSS3: does now really mean now?Chris Mills
 
Walk on the Client Side - Chris Mountford
Walk on the Client Side - Chris MountfordWalk on the Client Side - Chris Mountford
Walk on the Client Side - Chris MountfordAtlassian
 
Device aware web frameworks for better programming
Device aware web frameworks for better programmingDevice aware web frameworks for better programming
Device aware web frameworks for better programmingSuntae Kim
 
A brave new web - A talk about Web Components
A brave new web - A talk about Web ComponentsA brave new web - A talk about Web Components
A brave new web - A talk about Web ComponentsMichiel De Mey
 

Was ist angesagt? (20)

Responsive Enhancement
Responsive EnhancementResponsive Enhancement
Responsive Enhancement
 
Dynamic User Interfaces for Desktop and Mobile
Dynamic User Interfaces for Desktop and MobileDynamic User Interfaces for Desktop and Mobile
Dynamic User Interfaces for Desktop and Mobile
 
Responsive and Fast
Responsive and FastResponsive and Fast
Responsive and Fast
 
Thats Not Flash?
Thats Not Flash?Thats Not Flash?
Thats Not Flash?
 
Node.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash CourseNode.js & Twitter Bootstrap Crash Course
Node.js & Twitter Bootstrap Crash Course
 
Building single page applications
Building single page applicationsBuilding single page applications
Building single page applications
 
3D and VR on the web
3D and VR on the web3D and VR on the web
3D and VR on the web
 
Web Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing CombinationWeb Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing Combination
 
Responsive Web in Brief
Responsive Web in BriefResponsive Web in Brief
Responsive Web in Brief
 
More Than You Ever Wanted to Know About Resource Hints - Harry Roberts (CSS W...
More Than You Ever Wanted to Know About Resource Hints - Harry Roberts (CSS W...More Than You Ever Wanted to Know About Resource Hints - Harry Roberts (CSS W...
More Than You Ever Wanted to Know About Resource Hints - Harry Roberts (CSS W...
 
HTML5 and CSS3: does now really mean now?
HTML5 and CSS3: does now really mean now?HTML5 and CSS3: does now really mean now?
HTML5 and CSS3: does now really mean now?
 
Vue presentation
Vue presentationVue presentation
Vue presentation
 
Walk on the Client Side - Chris Mountford
Walk on the Client Side - Chris MountfordWalk on the Client Side - Chris Mountford
Walk on the Client Side - Chris Mountford
 
Webrender 1.0
Webrender 1.0Webrender 1.0
Webrender 1.0
 
Ic Efaces Glass Fish Ted Goddard
Ic Efaces Glass Fish Ted GoddardIc Efaces Glass Fish Ted Goddard
Ic Efaces Glass Fish Ted Goddard
 
Site optimization
Site optimizationSite optimization
Site optimization
 
Flash And Dom
Flash And DomFlash And Dom
Flash And Dom
 
Web Apps
Web AppsWeb Apps
Web Apps
 
Device aware web frameworks for better programming
Device aware web frameworks for better programmingDevice aware web frameworks for better programming
Device aware web frameworks for better programming
 
A brave new web - A talk about Web Components
A brave new web - A talk about Web ComponentsA brave new web - A talk about Web Components
A brave new web - A talk about Web Components
 

Ähnlich wie RESS – Responsive Webdesign and Server Side Components

Pinkoi Mobile Web
Pinkoi Mobile WebPinkoi Mobile Web
Pinkoi Mobile Webmikeleeme
 
The Future of CSS with Web components
The Future of CSS with Web componentsThe Future of CSS with Web components
The Future of CSS with Web componentsdevObjective
 
[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용NAVER D2
 
3 Approaches to Mobile - An A to Z Primer.
3 Approaches to Mobile - An A to Z Primer.3 Approaches to Mobile - An A to Z Primer.
3 Approaches to Mobile - An A to Z Primer.agup2009
 
Service Worker - Reliability bits
Service Worker - Reliability bitsService Worker - Reliability bits
Service Worker - Reliability bitsjungkees
 
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...Esri Nederland
 
Devon 2011-f-1 반응형 웹 디자인
Devon 2011-f-1  반응형 웹 디자인Devon 2011-f-1  반응형 웹 디자인
Devon 2011-f-1 반응형 웹 디자인Daum DNA
 
Testable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascriptTestable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascriptTimothy Oxley
 
Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020Matt Raible
 
Html5 - short intro
Html5 - short introHtml5 - short intro
Html5 - short introjeiseman
 
JavaScript Performance (at SFJS)
JavaScript Performance (at SFJS)JavaScript Performance (at SFJS)
JavaScript Performance (at SFJS)Steve Souders
 
JavaScript Perfomance
JavaScript PerfomanceJavaScript Perfomance
JavaScript PerfomanceAnatol Alizar
 
Keeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and WebpackKeeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and WebpackIgnacio Martín
 
[HEWEBAR 2012] Adaptive Images in Responsive Web Design
[HEWEBAR 2012] Adaptive Images in Responsive Web Design[HEWEBAR 2012] Adaptive Images in Responsive Web Design
[HEWEBAR 2012] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and moreYan Shi
 
Web app and more
Web app and moreWeb app and more
Web app and morefaming su
 

Ähnlich wie RESS – Responsive Webdesign and Server Side Components (20)

Pinkoi Mobile Web
Pinkoi Mobile WebPinkoi Mobile Web
Pinkoi Mobile Web
 
Presentation Tier optimizations
Presentation Tier optimizationsPresentation Tier optimizations
Presentation Tier optimizations
 
The Future of CSS with Web components
The Future of CSS with Web componentsThe Future of CSS with Web components
The Future of CSS with Web components
 
[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design[convergese] Adaptive Images in Responsive Web Design
[convergese] Adaptive Images in Responsive Web Design
 
125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용125 고성능 web view-deview 2013 발표 자료_공유용
125 고성능 web view-deview 2013 발표 자료_공유용
 
3 Approaches to Mobile - An A to Z Primer.
3 Approaches to Mobile - An A to Z Primer.3 Approaches to Mobile - An A to Z Primer.
3 Approaches to Mobile - An A to Z Primer.
 
Service Worker - Reliability bits
Service Worker - Reliability bitsService Worker - Reliability bits
Service Worker - Reliability bits
 
Death of a Themer
Death of a ThemerDeath of a Themer
Death of a Themer
 
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
Building mobile apps with the ArcGIS api for Javascript, Esri, Andy Gup and A...
 
Always on! Or not?
Always on! Or not?Always on! Or not?
Always on! Or not?
 
Devon 2011-f-1 반응형 웹 디자인
Devon 2011-f-1  반응형 웹 디자인Devon 2011-f-1  반응형 웹 디자인
Devon 2011-f-1 반응형 웹 디자인
 
Testable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascriptTestable client side_mvc_apps_in_javascript
Testable client side_mvc_apps_in_javascript
 
Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020Front End Development for Back End Java Developers - Jfokus 2020
Front End Development for Back End Java Developers - Jfokus 2020
 
Html5 - short intro
Html5 - short introHtml5 - short intro
Html5 - short intro
 
JavaScript Performance (at SFJS)
JavaScript Performance (at SFJS)JavaScript Performance (at SFJS)
JavaScript Performance (at SFJS)
 
JavaScript Perfomance
JavaScript PerfomanceJavaScript Perfomance
JavaScript Perfomance
 
Keeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and WebpackKeeping the frontend under control with Symfony and Webpack
Keeping the frontend under control with Symfony and Webpack
 
[HEWEBAR 2012] Adaptive Images in Responsive Web Design
[HEWEBAR 2012] Adaptive Images in Responsive Web Design[HEWEBAR 2012] Adaptive Images in Responsive Web Design
[HEWEBAR 2012] Adaptive Images in Responsive Web Design
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
 
Web app and more
Web app and moreWeb app and more
Web app and more
 

Mehr von Sven Wolfermann

Testing Responsive Webdesign
Testing Responsive WebdesignTesting Responsive Webdesign
Testing Responsive WebdesignSven Wolfermann
 
Fasten RWD Development with Sass
Fasten RWD Development with SassFasten RWD Development with Sass
Fasten RWD Development with SassSven Wolfermann
 
Typografie im Responsive Webdesign
Typografie im Responsive WebdesignTypografie im Responsive Webdesign
Typografie im Responsive WebdesignSven Wolfermann
 
Responsive Webdesign Process
Responsive Webdesign ProcessResponsive Webdesign Process
Responsive Webdesign ProcessSven Wolfermann
 
Webmontag karlsruhe – responsive images, maddesigns (sven wolfermann)
Webmontag karlsruhe – responsive images, maddesigns (sven wolfermann)Webmontag karlsruhe – responsive images, maddesigns (sven wolfermann)
Webmontag karlsruhe – responsive images, maddesigns (sven wolfermann)Sven Wolfermann
 
CSS3 im praktischen Einsatz
CSS3 im praktischen EinsatzCSS3 im praktischen Einsatz
CSS3 im praktischen EinsatzSven Wolfermann
 

Mehr von Sven Wolfermann (7)

Testing Responsive Webdesign
Testing Responsive WebdesignTesting Responsive Webdesign
Testing Responsive Webdesign
 
Fasten RWD Development with Sass
Fasten RWD Development with SassFasten RWD Development with Sass
Fasten RWD Development with Sass
 
Typografie im Responsive Webdesign
Typografie im Responsive WebdesignTypografie im Responsive Webdesign
Typografie im Responsive Webdesign
 
Responsive Images
Responsive ImagesResponsive Images
Responsive Images
 
Responsive Webdesign Process
Responsive Webdesign ProcessResponsive Webdesign Process
Responsive Webdesign Process
 
Webmontag karlsruhe – responsive images, maddesigns (sven wolfermann)
Webmontag karlsruhe – responsive images, maddesigns (sven wolfermann)Webmontag karlsruhe – responsive images, maddesigns (sven wolfermann)
Webmontag karlsruhe – responsive images, maddesigns (sven wolfermann)
 
CSS3 im praktischen Einsatz
CSS3 im praktischen EinsatzCSS3 im praktischen Einsatz
CSS3 im praktischen Einsatz
 

Kürzlich hochgeladen

Best VIP Call Girls Noida Sector 47 Call Me: 8448380779
Best VIP Call Girls Noida Sector 47 Call Me: 8448380779Best VIP Call Girls Noida Sector 47 Call Me: 8448380779
Best VIP Call Girls Noida Sector 47 Call Me: 8448380779Delhi Call girls
 
Cosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable BricksCosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable Bricksabhishekparmar618
 
Presentation.pptx about blender what is blender
Presentation.pptx about blender what is blenderPresentation.pptx about blender what is blender
Presentation.pptx about blender what is blenderUbaidurrehman997675
 
Cheap Rate Call girls Malviya Nagar 9205541914 shot 1500 night
Cheap Rate Call girls Malviya Nagar 9205541914 shot 1500 nightCheap Rate Call girls Malviya Nagar 9205541914 shot 1500 night
Cheap Rate Call girls Malviya Nagar 9205541914 shot 1500 nightDelhi Call girls
 
Cheap Rate ➥8448380779 ▻Call Girls In Huda City Centre Gurgaon
Cheap Rate ➥8448380779 ▻Call Girls In Huda City Centre GurgaonCheap Rate ➥8448380779 ▻Call Girls In Huda City Centre Gurgaon
Cheap Rate ➥8448380779 ▻Call Girls In Huda City Centre GurgaonDelhi Call girls
 
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅ Vashi Call Service Available Nea...
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅  Vashi Call Service Available Nea...Kurla Call Girls Pooja Nehwal📞 9892124323 ✅  Vashi Call Service Available Nea...
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅ Vashi Call Service Available Nea...Pooja Nehwal
 
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai DouxDubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Douxkojalkojal131
 
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...babafaisel
 
Cheap Rate Call girls Kalkaji 9205541914 shot 1500 night
Cheap Rate Call girls Kalkaji 9205541914 shot 1500 nightCheap Rate Call girls Kalkaji 9205541914 shot 1500 night
Cheap Rate Call girls Kalkaji 9205541914 shot 1500 nightDelhi Call girls
 
Editorial design Magazine design project.pdf
Editorial design Magazine design project.pdfEditorial design Magazine design project.pdf
Editorial design Magazine design project.pdftbatkhuu1
 
VIP College Call Girls Gorakhpur Bhavna 8250192130 Independent Escort Service...
VIP College Call Girls Gorakhpur Bhavna 8250192130 Independent Escort Service...VIP College Call Girls Gorakhpur Bhavna 8250192130 Independent Escort Service...
VIP College Call Girls Gorakhpur Bhavna 8250192130 Independent Escort Service...Suhani Kapoor
 
Verified Trusted Call Girls Adugodi💘 9352852248 Good Looking standard Profil...
Verified Trusted Call Girls Adugodi💘 9352852248  Good Looking standard Profil...Verified Trusted Call Girls Adugodi💘 9352852248  Good Looking standard Profil...
Verified Trusted Call Girls Adugodi💘 9352852248 Good Looking standard Profil...kumaririma588
 
The history of music videos a level presentation
The history of music videos a level presentationThe history of music videos a level presentation
The history of music videos a level presentationamedia6
 
VIP Kolkata Call Girl Gariahat 👉 8250192130 Available With Room
VIP Kolkata Call Girl Gariahat 👉 8250192130  Available With RoomVIP Kolkata Call Girl Gariahat 👉 8250192130  Available With Room
VIP Kolkata Call Girl Gariahat 👉 8250192130 Available With Roomdivyansh0kumar0
 
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...Call Girls in Nagpur High Profile
 
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130Suhani Kapoor
 
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...home
 
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130Suhani Kapoor
 

Kürzlich hochgeladen (20)

Best VIP Call Girls Noida Sector 47 Call Me: 8448380779
Best VIP Call Girls Noida Sector 47 Call Me: 8448380779Best VIP Call Girls Noida Sector 47 Call Me: 8448380779
Best VIP Call Girls Noida Sector 47 Call Me: 8448380779
 
Cosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable BricksCosumer Willingness to Pay for Sustainable Bricks
Cosumer Willingness to Pay for Sustainable Bricks
 
Presentation.pptx about blender what is blender
Presentation.pptx about blender what is blenderPresentation.pptx about blender what is blender
Presentation.pptx about blender what is blender
 
Cheap Rate Call girls Malviya Nagar 9205541914 shot 1500 night
Cheap Rate Call girls Malviya Nagar 9205541914 shot 1500 nightCheap Rate Call girls Malviya Nagar 9205541914 shot 1500 night
Cheap Rate Call girls Malviya Nagar 9205541914 shot 1500 night
 
Cheap Rate ➥8448380779 ▻Call Girls In Huda City Centre Gurgaon
Cheap Rate ➥8448380779 ▻Call Girls In Huda City Centre GurgaonCheap Rate ➥8448380779 ▻Call Girls In Huda City Centre Gurgaon
Cheap Rate ➥8448380779 ▻Call Girls In Huda City Centre Gurgaon
 
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
young call girls in Vivek Vihar🔝 9953056974 🔝 Delhi escort Service
 
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅ Vashi Call Service Available Nea...
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅  Vashi Call Service Available Nea...Kurla Call Girls Pooja Nehwal📞 9892124323 ✅  Vashi Call Service Available Nea...
Kurla Call Girls Pooja Nehwal📞 9892124323 ✅ Vashi Call Service Available Nea...
 
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai DouxDubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
Dubai Call Girls Pro Domain O525547819 Call Girls Dubai Doux
 
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
Kala jadu for love marriage | Real amil baba | Famous amil baba | kala jadu n...
 
Cheap Rate Call girls Kalkaji 9205541914 shot 1500 night
Cheap Rate Call girls Kalkaji 9205541914 shot 1500 nightCheap Rate Call girls Kalkaji 9205541914 shot 1500 night
Cheap Rate Call girls Kalkaji 9205541914 shot 1500 night
 
Editorial design Magazine design project.pdf
Editorial design Magazine design project.pdfEditorial design Magazine design project.pdf
Editorial design Magazine design project.pdf
 
VIP College Call Girls Gorakhpur Bhavna 8250192130 Independent Escort Service...
VIP College Call Girls Gorakhpur Bhavna 8250192130 Independent Escort Service...VIP College Call Girls Gorakhpur Bhavna 8250192130 Independent Escort Service...
VIP College Call Girls Gorakhpur Bhavna 8250192130 Independent Escort Service...
 
Verified Trusted Call Girls Adugodi💘 9352852248 Good Looking standard Profil...
Verified Trusted Call Girls Adugodi💘 9352852248  Good Looking standard Profil...Verified Trusted Call Girls Adugodi💘 9352852248  Good Looking standard Profil...
Verified Trusted Call Girls Adugodi💘 9352852248 Good Looking standard Profil...
 
escort service sasti (*~Call Girls in Prasad Nagar Metro❤️9953056974
escort service sasti (*~Call Girls in Prasad Nagar Metro❤️9953056974escort service sasti (*~Call Girls in Prasad Nagar Metro❤️9953056974
escort service sasti (*~Call Girls in Prasad Nagar Metro❤️9953056974
 
The history of music videos a level presentation
The history of music videos a level presentationThe history of music videos a level presentation
The history of music videos a level presentation
 
VIP Kolkata Call Girl Gariahat 👉 8250192130 Available With Room
VIP Kolkata Call Girl Gariahat 👉 8250192130  Available With RoomVIP Kolkata Call Girl Gariahat 👉 8250192130  Available With Room
VIP Kolkata Call Girl Gariahat 👉 8250192130 Available With Room
 
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
VVIP Pune Call Girls Hadapsar (7001035870) Pune Escorts Nearby with Complete ...
 
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130
VIP Call Girls Service Mehdipatnam Hyderabad Call +91-8250192130
 
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
 
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
VIP Call Girls Service Bhagyanagar Hyderabad Call +91-8250192130
 

RESS – Responsive Webdesign and Server Side Components

  • 1. RESS RWD and Server Side Components Sven Wolfermann | maddesigns
  • 2. Sven Wolfermann (36) · Freelancer for modern web development (HTML5, CSS3, jQuery) from Berlin · CSS3 Adventskalender 2010/2011 · wrotes articles and post for T3N-, PHP- and Webstandards-Magazin (new: Screengui.de) · mobile Geek · Twitter: @maddesigns · Web: http://maddesigns.de /
  • 3. www vs. m. desktop vs mobile /
  • 4. desktop vs. mobile dividing pages large site (feature rich) vs. small size (performant) /
  • 5. desktop vs tablet vs mobile dividing more pages? large site vs. tablet vs. small size vs. car vs. fridge vs. watch vs. … /
  • 6. Responsive Web Design A List Apart article by Ethan Marcotte /
  • 7. A List Apart is responsive too now
  • 8. Responsive Web Design · Flexible grids, based on percentage units · Variable image and video sizes – images fit into grid · CSS3 media queries image source: http://macrojuice.com/ /
  • 9. RWD solves many things · one URL, one code base, one deployment · all contents available (if not hidden) · Future friendly /
  • 10. moto.oakley.com · · 85.4MB page weight · 471 HTTP requests · 2 minutes 45 seconds until loading screen replaced with content · 4 minutes 10 seconds until onLoad event
  • 11. 85.4MB, 471 HTTP requests! THIS IS NOT RWD! Oakley's monster page of baubles /
  • 12. moto.oakley.com fail ok, ok, Oakley does it better now: JUST 14.2MB, 291 request (more than 70MB less) with mobile user-agent? 6.7MB, 114 requests :/ Oakley's Moto diet /
  • 13. RWD has some issues · site tend to be too large for mobile · some content is hard to adapt: images, tables, ads, ... · IE8 doesn't understand RWD (basically) /
  • 14. Guy Podjarny's RWD performance tests sites have nearly same weight on mobile as on desktop Real World RWD Performance – Take 2 /
  • 15. RWD is more Beyond Squishy: The Principles of Adaptive Design
  • 16. Performance · Reduce image payload (the biggest effect) · Reduce JavaScript and CSS payload · Further optimize based on feature detection Lightening Your Responsive Website Design With RESS /
  • 18. Testing browser features with Vanilla JS Cutting the mustard if('querySelector' in document && 'localStorage' in window && 'addEventListener' in window) { // bootstrap the javascript application } if browser supports 'querySelector', 'localStorage' and 'addEventListener' do hot stuff BBC Responsive News – Cutting the mustard /
  • 19. Modernizr Client side feature detection Modernizr is a JavaScript library that detects HTML5 & CSS3 features in the user's browser. http://modernizr.com/ /
  • 20. Modernizr throw in <head> <head> <script src="modernizr.js"></script> </head> Modernizr features test: geolocation Modernizr.geolocation // true or false if (Modernizr.geolocation) { navigator.geolocation.getCurrentPosition(show_map); } else { // no native support; maybe try a fallback? } /
  • 21. Modernizr Modernizr can load different files based on tests Modernizr.load({ test: Modernizr.geolocation, yep : 'geo.js', nope: 'geo-polyfill.js' }); Modernizr.load is not part of the "development" version Modernizr adds classes to <html> <html class="js flexbox canvas canvastext webgl no-touch geolocation postmessage hashchange history boxshadow cssanimations csscolumns cssgradients csstransforms csstransforms3d csstransitions fontface video audio localstorage svg inlinesvg"> /
  • 22. Modernizr Another Sample: datepicker <script src="modernizr.js"></script> <script> Modernizr.load({ test: Modernizr.inputtypes.date, nope: ['jquery.datepicker.js', 'jquery.datepicker.css'], complete: function () { $('input[type=date]').datepicker({ dateFormat: 'yy-mm-dd' }); } }); </script> load jQuery datepicker library for browsers that don't have native datepickers /
  • 26. Conditional loading – window.matchMedia Returns a new MediaQueryList object representing the parsed results of the specified media query string. if (window.matchMedia("(min-width: 40em)").matches) { /* load secondary stuff */ } matchMedia Polyfill Modernizr.load and Picturefill uses matchMedia for example MDN Window.matchMedia /
  • 27. Conditional loading – Modernizr.load Modernizr loads scripts and CSS based on media queries Modernizr.load([ { test: Modernizr.mq("only screen and (min-width: 1051px)"), yep: '/js/large.js' }, { test: Modernizr.mq("only screen and (min-width: 600px) and (max-width: 1050px)"), yep: '/js/medium.js' }, { test: Modernizr.mq("only screen and (min-width: 320px) and (max-width: 599px)"), yep: '/js/small.js' } ]); you can use EM in media queries too ;) /
  • 28. Conditional loading – pairing CSS & JS holding CSS and JavaScript Breakpoints in sync body:after { content: 'small'; display: none; } @media (min-width: 650px) { body:after { content: 'middle'; } } @media (min-width: 1200px) { body:after { content: 'large'; } } /
  • 29. Conditional loading – pairing CSS & JS holding CSS and JavaScript Breakpoints in sync var size = window.getComputedStyle(document.body,':after') .getPropertyValue('content'); if (size == 'large') { // Load some more content. } Conditional CSS /
  • 30. Conditional loading – Ajax-include pattern Replace: <a href="..." data-replace="latest/fragment">Latest Articles</a> Before: <a href="..." data-before="latest/fragment">Latest Articles</a> After: <a href="..." data-after="latest/fragment">Latest Articles</a> init with jQuery: $("[data-replace],[data-before],[data-after]").ajaxInclude(); An Ajax-Include Pattern for Modular Content /
  • 32. Browser-Sniffing remember the old days? Not? You lucky guy! UA-string history Browser-Sniffing went wrong /
  • 33. Browser-Sniffing is hard and unreliable For example, Safari user agent string on an iOS7 iPhone: Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/546.10 (KHTML, like Gecko) Version/6.0 Mobile/7E18WD Safari/8536.25 often browsers aims other browsers detecting the "right" user agent is complicated Parsing UA string is not a regex job UA-Detection libraries /
  • 34. What?! UA-Sniffing is wild guessing
  • 35. This is NOT a "mobile" detection! if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { if (document.cookie.indexOf("mobile_redirect=false") == -1) { window.location = "http://m.yoursite.com/"; } } more like this // Check if UA is mobile (from http://detectmobilebrowsers.com/) if(/(android|bbd+|meego).+mobile|avantgo|bada/|blackberry |blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris |kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)? |phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian |treo|up.(browser|link)|vodafone|wap|windows (ce|phone) |xda|xiino/i.test(agent) { isUAMobile = true; } /
  • 37. Device Detection Libraries · WURFL (Java/.NET/PHP) free * · Scientiamobile (Java/.NET/PHP) commercial * · Device Atlas (Java/.NET/PHP) commercial · Netbiscuits' Device Library commercial · 51degrees (.NET, C, Java, PHP) free limited / commercial · Open DDR (Java/.net) Open Source · Mobile Detect (PHP) Open Source * / free with restricted license
  • 38. Device Detection Libraries Problems · updates are slow · not reliable /
  • 39.
  • 41. Client meets Server set browser width cookie with JS RESS = {}; RESS.writeCookie = function (name, value) { //cookie code } //Store width in a cookie RESS.storeSizes = function () { //Get screen width var width = window.innerWidth; // Set a cookie with the client side capabilities. RESS.writeCookie("RESS", "width." + width); } RESS.storeSizes(); /
  • 42. Client meets Server use cookie info in code Setting a file path based on window.innerWidth <?php // grab the cookie value $screenWidth = $_COOKIE['RESS']; // set the img path var if ($screenWidth <= 320) { $imgPath = "320"; } else if ($screenWidth < 960) { $imgPath = "640"; } else { $imgPath = "960"; } // print out our image link print "<img src='/rwd/images/".$imgPath."/car.jpg' alt='Car' />"; ?> http://www.netmagazine.com/tutorials/getting-started-ress /
  • 43. Client meets Server use cookie info in code <?php if ($RESS["width"] >= 320 && $RESS["width"] <= 640) { ?> <div class="mobile-ad max-320"> <?php include "/ads/320.php"?> </div> <?php } ?> /
  • 44. Modernizr Server Client features for the server <?php include('modernizr-server.php'); print 'The server knows:'; foreach($modernizr as $feature=>$value) { print " $feature: "; print_r($value); } ?> The server knows: canvas: 1 geolocation: 1 crosswindowmessaging: 1 indexeddb: 0 hashchange: 1 ... https://github.com/jamesgpearce/modernizr-server /
  • 45. RESS Responsive Web Design + Server Side Components /
  • 47. “ In a nutshell, RESS combines adaptive layouts with server side component (not full page) optimization. So a single set of page templates define an entire Web site for all devices but key components within that site have device-class specific implementations that are rendered server side. ” —Luke Wroblewski @lukew http://www.lukew.com/ff/entry.asp?1392 /
  • 48. Sapient Nitro about RESS http://www.youtube.com/embed/XhCXINNvmv8 /
  • 49. Advantages of RESS · Easier to navigate: The navigation structure can be customized for the different tasks. · Less page bloat: Instead of relying on display: none; or visibility: hidden; to hide page elements for mobile devices, removed from the HTML or CSS. · Faster load time: Unnecessary CSS/JavaScript can be removed from the HTML /
  • 50. Disadvantages of RESS · More server resources: Dynamically building the HTML will increase the load on the server. · Caching: A need for a better caching mechanism · Requires device detection: Mobile users will need to be detected. Device detection is unreliable. /
  • 51. RESS in the wild? -> Adaptive Images http://adaptive-images.com/ /
  • 53. Adaptive Images · Add .htaccess and adaptive-images.php to your document-root folder. · Add one line of JavaScript into the <head> of your site. · Add your CSS Media Query values into $resolutions in the PHP file. /
  • 54. Adaptive Images 1. The HTML starts to load in the browser and a snippet of JS in the <head> writes a session cookie, storing the visitor's screen size in pixels. 2. The browser then encounters an <img> tag and sends a request to the server for that image. It also sends the cookie, because that’s how browsers work. 3. Apache receives the request for the image and immediately has a look in the website's .htaccess file, to see if there are any special instructions for serving files. 4. There are! The .htaccess says "Dear server, any request you get for a JPG, GIF, or PNG file please send to the adaptive-images.php file instead." /
  • 55. Adaptive Images 5. The PHP file looks for a cookie and finds that the user has a maximum screen size of 480px. 6. It compares the cookie value with all $resolution sizes that were configured, and decides which matches best. In this case, an image maxing out at 480px wide. 7. It then has a look inside the /ai-cache/480/ folder to see if a rescaled image already exists. 8. We'll pretend it doesn’t - the PHP then goes to the actual requested URI to find the original file. 9. It checks the image width. If that's smaller than the user's screen width it sends the image. 10. If it's larger, the PHP creates a down-scaled copy and saves that into the /ai-cache/480/ folder ready for the next time it's needed, and sends it to the user. http://adaptive-images.com/ /
  • 56. Responsive Images a topic for itself… Responsive Images [german] /
  • 58. Detector (PHP RESS library) combines UA-parsing and feature testing · includes User Agent parser – record any useful information (like OS or device name) · includes Modernizr Server no need for commercial device detection libraries add your own feature tests and store the results using Modernizr's addTest() API /
  • 59. Detector 1.· HTTP request hits server 2.· Detector compares User-Agent with database 3.· if known, classify device and get back content 4.· if not, Modernizr makes feature detection, stores cookie 5.· reloads site, gives back specified content 6.· stores UA-String/features combination for later use How Detector works /
  • 60. Detector device families The default install of Detector will categorize browsers into one of three families. // families.json { "tablet": { "isTablet": true }, "mobile-advanced": { "isMobile": true, "features": ["cssanimations","localstorage","deviceorientation"] }, "mobile-basic": { "isMobile": true }, "desktop": { "isComputer": true } } /
  • 61. Detector sample switch ads, basic sample if ($ua->family == 'mobile-basic') { include "/ads/simple.php"; } elseif ($ua->family == 'mobile-advanced') { include "/ads/responsive-ads.php"; } else { include "/ads/desktop.php"; } Detector video sample if ($ua->video->h264 || $ua->video->webm) { print $html5Embed; // YouTube's <iframe> code } else { print $simpleLink; } /
  • 62. RESS examples University of Notre Dame West Virginia University CNN Scientiamobile /
  • 63. RESS isn't the holy grail (RWD isn't either)
  • 64. RESS – further reading Templating with Detector & Mustache for RESS Is Adaptive Web Design Or RESS Better Than Responsive Design For SEO? Adaptation: Why responsive design actually begins on the server /
  • 66. Client Hints Client Hints is a new proposal by Ilja Grigorik and will allow clients to indicate a list of device and agent specific preferences. Spec Draft (request) GET /img.jpg HTTP/1.1 User-Agent: Awesome Browser Accept: image/webp, image/jpg CH: dpr=2.0 (response) HTTP/1.1 200 OK Server: Awesome Server Content-Type: image/jpg Content-Length: 124523 Vary: CH (image data) Automating DPR switching with Client-Hints /
  • 67. Client Hints For example, given the following request header: CH: dh=598, dw=384, dpr=2.0 The server knows that the client's screen height is 598px, width is 384px, as measured by density independent pixels on the device, and that the device pixel ratio is 2.0. /
  • 68. Client Hints ReSrc.it can handle client hints now /
  • 69. Questions? Thanks for your attention! Sven Wolfermann | maddesigns http://maddesigns.de/RESS/ HTML5 slideshow by Google /