Responsive Web Design (RWD) is a giant leap in the right direction for web on mobile devices. However, RWD is just a small, part of the big picture. What we really want is for the whole value chain to be responsive, not only in the browser., There are a vast number of frameworks and tools on the webs for implementing RWD. Most of these provide a great starting point for mobile ventures. However, there are not so many tools out the to help you with the rest of the value chain. Especially tools that are easy to use and provide a relatively small footprint for front end developers., This talk will explore possibilities you get when you combine the best practices from the client side, with best practices from the server side. Sometimes this technique is called RESS, or Adaptive Design. The talk will contain coding, code samples and best practices based on popular frameworks and tools for Adaptive Design that combines client side and server side techniques. Results, effects and gains in terms of performance will also be documented and exemplified., The audience will gain insights into how their next project can perform even better in mobile devices and smart ways to reduce data traffic, increase speed and be more future friendly by utilizing the server for heavy-lifting.
3. 100 ms faster:
1% increased revenue
1 sec delay:
2.8% drop in revenue
http://www.slideshare.net/stubbornella/designing-fast-websites-presentation
http://slideshare.net/markstanton/speed-matters
SLOW IS NOT COOL
...even less cool on mobile
For Q3 2013 that is $17mill.
4. THE VALUE CHAIN
developer server internet telco
network device
Doesn’t really make things more
difficult, but reveal a few issues
browser
5. WHY IS MOBILE SLOWER?
• Network Latency
• Available Bandwidth
• The Implementation
• Processing Power
• Browser
• Battery Preserving Strategies
• Memory
6. FUN-FACT
Loading apple.com consume
1.41% of battery life.
http://www2012.wwwconference.org/proceedings/proceedings/p41.pdf
Not so
12 - 4% in 8 mins
of web surfing
10. 1.8 MB
in 95 requests on average
• Avg. speed: 2Mbps (cisco)
• 1 Mbps = 0.12 MB/s
• 1.8 / 0.24 = 7,5s
7,5Seconds
download
time
http://www.cisco.com/en/US/solutions/collateral/ns341/ns525/ns537/ns705/ns827/white_paper_c11-520862.html
11. 1.8 MB
in 95 requests on average
•100-200 ms pr roundtrip
•Depends....(DNS, pipelining,
concurrentTCP connections
etc.)
9,5Seconds
latency in
total
12. LATENCY
3g 4g
Control plane 200–2,500 ms 50–100 ms
DNS lookup 200 ms 100 ms
TCP handshake 200 ms 100 ms
TLS handshake 200–400 ms 100–200 ms
HTTP request 200 ms 100 ms
Total latency overhead 200–3500 ms 100–600 ms
O’Reilly: High Performance Browser Networking
14. .01 s.
User opens app.
Wakes the radio. Device
sends a request to the cell
tower to use the network
Tower signaling.
Device promoted to full
power state. Process
takes about 2 seconds
2.1 s.
Only needed when
device is idle
App is “on line”
App does a DNS lookup.
Roundtrip is 100-200 ms.
2.2 s.
15. Latency,
anything from
100 - >500ms
TCP connection
HTML document returned
2.4 s.
2.4 s, the
HTML page is
downloaded
Browser rendering
Fetches linked resources.
More DNS lookups (one for
each unique domain) and
TCP connections.
2.6 s.
Page displayed
Puh...
3-60 s.
http://www.research.att.com/articles/featured_stories/2011_03/201102_Energy_efficient?fbid=YmB5ErqPR7b
16. 1.8 MB
in 95 requests on average
•Wake up radio (one time)
•TCP and DNS (one time)
•95 round trips (6 req pr conn.)
•Downloading 1.8 mb over 2Mbps
11,2Seconds
total
+ rendering time in the browser
+ server response time
Disclaimer: lots of assumptions in this calculation!
17. GOOGLE: 7.5 S.
*at the time, the average web site was 1,2MB. Minus the 2s wakeup, we’re in the
ballpark.
19. SERVE A PAGE TO A MOBILE DEVICE IN
LESS THAN 1 SECOND?
A great overview by Ilya Grigorik
bit.ly/mobile-barrier
20. WHO CARES?
The users care!
Telco Network
53,53 %
Other
46,47 %
How users connect. Page views per connection
type. (Scandinavian Countries). Source:
Mobiletech
25. RWD IS A TECHNIQUE
Nothing wrong with the technique! It is brilliant!
The famous Iceberg: @brad_frost
26. RWD != MOBILE FRIENDLY
but an important step in the right direction
27. Load time: 9.07s *
Size: 288.14 kb
Load time: 2.36 s *
Size: 36.59 kb
*) Load event fired. - More on how the built the new BBC News site: http://slidesha.re/14IYNOO
42. PURPOSE OF RESS
• Reduce need for client side
processing
• Eliminate “over downloading”
• Let the server do the work
instead of the browser
43. RESS IN A NUT SHELL
•RWD provide a sensible default or fallback
•The server does the optimization
Reduce asset size
Selective markup
Ad serving
Social networks
Minify
zip
Cache
etc.
44. INGREDIENTS OF RESS
Hello, I know exactly how to make you shine!
Information about the
requesting device,
network, etc.
Request/Response
45. NOT A CRIME!
82% of top 100 Alexa sites use
Device Detection
In the case of
Mashable, we also
detect the type of
device and change
the site’s behavior
accordingly.
“
”
http://www.circleid.com/posts/20120111_analysis_of_server_side_mobile_web_detection/
http://mashable.com/2012/12/11/responsive-web-design/
46. THERE IS A DIFFERENCE
User-Agent sniffing
var
isIpad
=
/iPad/i.test(navigator.userAgent);
Feature Detection
var
appCache=
function()
{
return
!!window.applicationCache;
};
Device Detection
Using the User-Agent (++) as a key to look up in a data base.
http://www.otsukare.info/2013/10/02/ua-parsing
48. FEATURES OF A DDR
• Nice place to store custom stuff
• “Business rules”
• Specifics to your site
• Override feature detected features
• If a feature works, but not well enough to make it useable
• False positives (not a HUGE issue, but still)
• Available server side too
• Adapt and optimize stuff before sending to client
Device Description
Repository
56. EXAMPLE
<div
data-‐picture
data-‐alt="A
beautiful
butterfly">
<div
data-‐src="http://img.demo.wew.io/px_100/http://exampe.com/image.png"></div>
<div
data-‐src="http://img.demo.wew.io/px_320/http://exampe.com/image.png"
data-‐media="(min-‐width:
320px)"></div>
<div
data-‐src="http://img.demo.wew.io/px_320/@_2/http://exampe.com/image.png"
data-‐media="(min-‐width:
320px)
and
(-‐webkit-‐min-‐device-‐pixel-‐ratio:
2.0)"></div>
!
<noscript>
<img
src="http://img.demo.wew.io/px_10/http://exampe.com/image.png">
</noscript>
</div>
Picturefill: https://github.com/scottjehl/picturefill.
Using Picturefill
57. CSS OPTIMIZATION
Device Capabilities as Media Features
Removing overhead and excess styles
@media
(-‐wew-‐pointing-‐method:
touchscreen){
a
{
padding:
10px;
}
}
@media
all
and
(min-‐width:
1500px){
//removed
for
devices
where
1500px
is
impossible.
e.g.
iPhones
body{color:
green;}
}
Server Side rendering
58. EXAMPLE
<!doctype
html>
<html>
<head>
!
<link
rel="stylesheet"
href="//css.demo.wew.io/http://example.com/style.css”/>
!
</head>
<body>
!
<img
src="http://img.demo.wew.io/http://example.com/image.jpg"/>
!
<script>
var
w=new
wew();
w.getSet("myset",cb);
</script>
!
</body>
</html>
•Markup lives anywhere
•CSS and images are proxied,
optimized and cached
•Device data available client side
63. FUN-FACT
Loading apple.com consume 1.41% of battery
life.
http://www2012.wwwconference.org/proceedings/proceedings/p41.pdf
Not so
12 - 4% in 8 mins of
web surfing
67. THE RULES
1. Make Fewer HTTP Requests
2. Use a Content Delivery Network
3. Add an Expires Header
4. Gzip Components
5. Put Stylesheets at theTop
6. Put Scripts at 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
14. Make AJAX Cacheable
By Steve Souders: http://stevesouders.com/hpws/rules.php
Most of these are
implemented
server side.
68. SUMMING UP
developer server internet telco
network device browser
We...
...must do stuff
here...
...to
relieve...
...and...
...to make life
easier for...
...and...
69. THANK YOU
John Arne Sæterås
Twitter: @jonarnes
VP of innovation at ScientiaMobile.com
http://www.slideshare.net/jonarnes/