SlideShare a Scribd company logo
HtMl5 eXpErTiSeaTyOuRsErViCe	
  
LaUrISvAn @lAuRiSvAn
Sc5OnLiNe @sC5
EnGiNeErInGHtMl5aPpLiCaTiOnS
fOr bEtTeR pErFoRmAnCe
“GiVemEsOmEtHiNgtHaTIcAnUsE”
15YeArSReTrOsPeCtIvEoFMyPeRsOnAlGeAr
1000 tImEstHesPeEdiN15yEaRs
  CPU Display Connection
Network
Speed / bps
CPU /
MFLOPS Pixels
1994 80486 640x480 modem 14,400 3 307,200
1999 AMD Athlon 500 1024x768 ISDN 128,000 180 786,432
2003 AMD Athlon Tbird 1600x1200 cable modem 300,000 373 1,920,000
2010 Intel Core i5 HDMI cable modem 4,000,000 4,256 4,096,000
1000tImEs tHeCpU,20tImEstHeBaNdWiDtHtODrAw
aPiXeL
web	
  pages?	
  
slow	
  web	
  pages!	
  
pre.y	
  	
  good	
  pages	
  
(in	
  desktop)	
  
OreVeN20tImEsfAsTeR?
SoDowEFeEl OuR ApPsrUn1000
tImEs fAsTeR?
3 tImEsfAsTeR?
WegOtuSeDToCrEaTiNgSlUgGiShWeBSeRvIcEs
AttHeSaMetImE,ApPlEdElIvErEd aSlIcKApPExPeRiEnCe
ı7
2005	
   2007	
   2009	
   2011	
   2013	
  
Web	
  
1G	
  Smartphone	
  
iPhone	
  
PC	
  
UsEreXpErIeNcE	
  
WehAvETrAdEdPeRfOrMaNcEfOrEvErYtHiNgElSe
•  Distributing the data & computation far away
personal computing à web services à mobile & cloud
•  Consuming increasingly rich data
Text à Images à Videos
•  Moving to highly abstracted & interpreted languages
C à Java à JavaScript
WeBSiTeSStIlLGeTBiGgEr
NoV2010-SePt2013StAtS,HtTpArChIvE/StEvESoUdErS
MoBiLeDeViCeS-5yEaRsBaCkiNCpUSpEeD,
10yEaRsBaCkiNCoNnEcTiOnBaNdWiDtH
 
Samsung
Galaxy S4
My Machine
(2003)
My Machine
(2010)
CPU / MFLOPS 1500 373 4,256
Display / Pixels 2073600 1,920,000 4,096,000
Connection Speed / bps 384000* 300,000 4,000,000
*	
  Assuming	
  3G/UMTS	
  safe	
  speed,	
  due	
  to	
  low	
  adopNon	
  of	
  4G	
  networks	
  
2005	
   2007	
   2009	
   2011	
   2013	
  
Web	
  
iPhone	
  
HTML5	
  
HtMl5&WeBApPsTo ChAlLeNgE
NaTiVeApPsiN SlIcKnEsS
ı11
UsEreXpErIeNcE	
  
UNlizing	
  HW	
  
accelerated	
  graphics,	
  
offline	
  assets,	
  
advanced	
  gestures	
  
and	
  high	
  perf	
  JS	
  
engines	
  
LeT’sTaRgEtfOrMoBiLeApPPeRfOrMaNcE
•  1s app startup time (first page load time)
•  1s for any subsequent view/page (reasonable delay)
•  100ms UI response time (noticeable delay)
•  16ms paints (LCDs will refresh 50-60Hz, the rest is surplus)
HTML5 App
•  1000 DOM elements
•  1Mb of images and 100
network requests on page
load
How about these?
•  1s first page fold
Native App
•  1000 widgets?
•  1Mb of images and 100
network requests on app
startup?
•  1s application install?
WeBeNgInEsaReqUiTe fAsT!
LeT’suSetHesAmEyArDsTiCkwHeNmEaSuRiNg
IfyOuR eMuLaToRrUnS20tImEs
fAsTeR tHaN tHeTaRgEt,wHaTcAn
yOueXpEcT aBoUtPeRfOrMaNcE?
LeT’sEnGiNeErtHeWeB ApPstHe
SaMewAyApPsArEEnGiNeErEd
oNe-sEcOnDPaGeLoAdS
OnESeCoNdBuDgEt
•  Turn on radio 300ms!
•  DNS lookup + 150ms!
•  SSL handshake + 200ms!
•  Process & load HTML & other resources + 200ms!
•  Parse à Layout à Paint = 150ms!
SiMuLaTeSlOwPaGeSpEeDs
•  Developers tend to have ultra-fast computers & networks and forget
the Egde & 3G network
•  Tip: Network Link Conditioner XCode Plugin & ipfw rules
AsImPlEsImUlAtIoNShElLScRiPt
#!/bin/sh!
#!
# simulate_3g.sh - Simulate a sluggish 3G network with delays & packet loss!
# Usage: simulate_3g.sh 8080 8081!
!
# Make sure only root can run our script!
if [[ $EUID -ne 0 ]]; then!
echo "This script must be run as root" 1>&2!
exit 1!
fi!
!
# Simulate http over 3G, 300kbit/s with 5% packet loss and 200ms delays!
# into all ports given as a parameter!
ipfw pipe 1 config delay 200 plr 0.1 bw 300kbit/s!
for var in "$@"!
do!
ipfw add 1 pipe 1 dst-port $var!
done!
CoMbInEaNdCoMpReSsyOuRReSoUrCeS
•  Combine and minify your CSS and JavaScript
•  Combine small icons into a sprite sheet
•  Squeeze the last bits from your images: It is much easier to
remove 100k from your images than your JavaScript code!
•  Tip: You should automate this, e.g. using Grunt
CaChInGtHeAsSeTs
•  CDNs for caching assets close to the user
•  Varnish, Squid, Nginx etc. in front of your app server
•  Having the CDNs and caches working requires good
headers from your app server, too
•  Tip: Let your Apache/Nginx reverse proxy care for your
headers, they usually do it much better than you do
Cache-Control: public, max-age=0

!Etag: "91580-1380653643000“

!Last-Modified: Tue, 01 Oct 2013 18:54:03 GMT!
ShArDfOrSeVeRaLDoMaInS
•  Modern browsers limit to 6 connections per host your non-
scripted resources (e.g. CSS, images) from several hosts
•  Severe problem because HTTP 1.1 requires the resources
to be sent in the order they were requested
•  Note: Remember the browser security rules, particularly
CORS and Same-origin policy
If yOuStIlLgOtTiMetOOpTiMiZePaGeLoAdS
•  Optimize for the first page fold: Critical CSS and JS
embeded
•  Optimize for connection drops & offline: Application Cache
•  Batch your API calls
•  Serve responsive images, prepare for the W3C adaptive
images extension
!<img alt="The Breakfast Combo” src="banner.jpeg”

! !srcset="banner-HD.jpeg 2x,

! !banner-phone.jpeg 100w,

! !banner-phone-HD.jpeg 100w 2x”>!
60fRaMeSScRoLlaNdAnImAtIoN
OlD-ScHoOlOpTiMiZaTiOnSWoN’tHeLpYoU
•  JavaScript is typically not your problem
•  CSS selector lengths typically have only a minor impact
•  Browsers spend ~90% of its computation layouting and
painting
What you want to track is
•  The causes of relayout and repainting
•  What their costs are
•  Tip: Watch out adding/removing classes & hovering
“TyPiCaL PaInTLoOp”
FuncNon	
  
call	
  /	
  Event	
  
Recalculate	
  
Style	
  
Layout	
  
Paint	
  
Composite	
  
Layers	
  
JavaScript	
  Engine	
  (CPU	
  /	
  Virtual	
  Machine)	
  
Render	
  Tree	
  &	
  Layout	
  Engine	
  (CPU)	
  
Paint	
  Engine	
  (CPU)	
  
Compositor	
  (GPU)	
  
AlL CsSOpErAtIoNsaReN’tEqUaL
•  Geometry changing ops: Layout, repaint, compositing
•  width, height etc…
•  Paint-only ops: Repaint & compositing only
•  borders, outlines, box shadow, etc…
•  Composition only (or less): Things that are 100% in GPU
•  CSS3 Transforms, Opacity
OpTiMiZiNgLaYoUtS&PaInTs
•  Avoid DOM reads after geometry changing DOM
operations
•  Avoid a few expensive paint operations (shadows, border
radius, flexbox etc…)
•  Use translateZ(0) hack if you need a HW accelerated
element
•  Use CSS3 transforms for animating, they will not cause
reflows
1/10sEcOnDtOReSpOnD,
OnEsEcOnDtOsHoWThErEsUlTs
TrAdItIoNaLPaGeSDoN’tDo aNyThInGuNtIlyOu TeLl
*click*	
   *click*	
  
Tradi&onal	
  
ImMeDiAtEFeEdBaCkbUySYoU tImE
OvErAlLpErFoRmAnCemAygEtfAsTeR,tOo
*click*	
   *click*	
  
Feedback	
  
PrElOaDiNg&BoOtStRaPpInGToShOwtHeNeXtPaGeFaStEr
YoUMaYHuRt YoUrSeLfBaD!
*click*	
  
+	
  
*click*	
  
Preloading	
  
Bootstrapping	
  
LaZyLoAd -OpTiMiZiNgfOrtHeFiRsTPaGeFoLd
+	
   +	
  
1st	
  fold	
  inlined	
   Rest	
  of	
  the	
  page	
  as	
  
separate	
  resources	
  
+	
  
Lazy	
  Load	
  
PeRfOrMaNcEiSnOExCePtIoN.AtsOmEpOiNtyOuRaRcHiTeCtUrE
wIlL fIgHtaGaInStyOu.
QuAlItYAtTrIbUtEsoFyOuRaPpaRe
sEtbYyOuRArChItEcTuRe.
ReCaP:GeTtInGtOtHepErFoRmAnCetArGeTs
•  Set the performance goals, prepare for tradeoffs
•  Track the goals from the beginning
•  Don’t guess; measure
•  Simulate the target performance as part of your daily work
•  Keep your code simple, don’t trade it for performance
•  Perfect is the enemy of the good
ThAt’sAlL!
AnYQuEsTiOnS?
HtMl5 eXpErTiSeaTyOuRsErViCe	
  
LaUrISvAn
ThAnKyOu!
Software Architect, SC5 Online Ltd
https://github.com/laurisvan
https://twitter.com/laurisvan

More Related Content

PDF
Engineering HTML5 Applications for Better Performance
PDF
Mobile Web Speed Bumps
PDF
Keypoints html5
PDF
Snakes on the Web
PDF
Web Page Test - Beyond the Basics
PPTX
Browser Wars Episode 1: The Phantom Menace
PDF
Mobile Web Performance - Getting and Staying Fast
PDF
Are Today’s Good Practices… Tomorrow’s Performance Anti-Patterns?
Engineering HTML5 Applications for Better Performance
Mobile Web Speed Bumps
Keypoints html5
Snakes on the Web
Web Page Test - Beyond the Basics
Browser Wars Episode 1: The Phantom Menace
Mobile Web Performance - Getting and Staying Fast
Are Today’s Good Practices… Tomorrow’s Performance Anti-Patterns?

What's hot (20)

PDF
Speed is Essential for a Great Web Experience
PDF
The Case for HTTP/2 - Internetdagarna 2015 - Stockholm
PDF
What does the browser pre-loader do?
PDF
Are Today’s Good Practices… Tomorrow’s Performance Anti-Patterns?
PDF
Pagespeed what, why, and how it works
PDF
Real World Web Standards
PDF
Front end performance tip
PDF
Speed Matters!
PDF
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)
PDF
Front End Performance
PDF
Killing the Angle Bracket
PDF
Tuning Web Performance
ODP
SPI server centric SEO compatible stateless web sites... ALLELUIA!
KEY
Flash And Dom
KEY
Thats Not Flash?
PDF
Performance automation 101 @LDNWebPerf MickMcGuinness
PDF
CouchDB Google
PPTX
Front end performance optimization
PDF
HTML5 and the dawn of rich mobile web applications pt 1
PDF
How to choose a web framework and be surprised
Speed is Essential for a Great Web Experience
The Case for HTTP/2 - Internetdagarna 2015 - Stockholm
What does the browser pre-loader do?
Are Today’s Good Practices… Tomorrow’s Performance Anti-Patterns?
Pagespeed what, why, and how it works
Real World Web Standards
Front end performance tip
Speed Matters!
Progressive Enhancement 2.0 (jQuery Conference SF Bay Area 2011)
Front End Performance
Killing the Angle Bracket
Tuning Web Performance
SPI server centric SEO compatible stateless web sites... ALLELUIA!
Flash And Dom
Thats Not Flash?
Performance automation 101 @LDNWebPerf MickMcGuinness
CouchDB Google
Front end performance optimization
HTML5 and the dawn of rich mobile web applications pt 1
How to choose a web framework and be surprised
Ad

Viewers also liked (6)

PDF
Miten design-muutosjohtaminen hyödyttää yrityksiä?
PDF
Helsinki Serverless Meetup 15.6.2016 : AWS Services
PDF
2013 10-02-backbone-robots-aarhus
PDF
Securing the client side web
PDF
Angular.js Primer in Aalto University
PDF
2013 04-02-server-side-backbone
Miten design-muutosjohtaminen hyödyttää yrityksiä?
Helsinki Serverless Meetup 15.6.2016 : AWS Services
2013 10-02-backbone-robots-aarhus
Securing the client side web
Angular.js Primer in Aalto University
2013 04-02-server-side-backbone
Ad

Similar to 2013 10-02-html5-performance-aarhus (20)

PDF
Performance Oriented Design
PPTX
Old code doesn't stink - Detroit
PDF
Scaling a Rails Application from the Bottom Up
PDF
Extreme Web Performance for Mobile Devices
PDF
OpenCL & the Future of Desktop High Performance Computing in CAD
PDF
Capacity Planning for fun & profit
PDF
Design for Scale / Surge 2010
PDF
Robotics technical Presentation
PPTX
Big Memory for HPC
PDF
Network Automation with Salt and NAPALM: Introuction
PDF
Optimizing browser experience - App!mobile 2013 conf
PDF
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...
PDF
Castles in the Cloud: Developing with Google App Engine
PDF
Building a better web
PPTX
Old code doesn't stink
PPTX
Being HAPI! Reverse Proxying on Purpose
PDF
Does This Theme Make My Website Look Fat? (Wordcamp SLC 2013)
PPTX
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
PDF
Analyzing OS X Systems Performance with the USE Method
PDF
[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary
Performance Oriented Design
Old code doesn't stink - Detroit
Scaling a Rails Application from the Bottom Up
Extreme Web Performance for Mobile Devices
OpenCL & the Future of Desktop High Performance Computing in CAD
Capacity Planning for fun & profit
Design for Scale / Surge 2010
Robotics technical Presentation
Big Memory for HPC
Network Automation with Salt and NAPALM: Introuction
Optimizing browser experience - App!mobile 2013 conf
XPDS16: Xen Live Patching - Updating Xen Without Rebooting - Konrad Wilk, Ora...
Castles in the Cloud: Developing with Google App Engine
Building a better web
Old code doesn't stink
Being HAPI! Reverse Proxying on Purpose
Does This Theme Make My Website Look Fat? (Wordcamp SLC 2013)
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
Analyzing OS X Systems Performance with the USE Method
[DBA]_HiramFleitas_SQL_PASS_Summit_2017_Summary

More from SC5.io (7)

PDF
AWS Machine Learning & Google Cloud Machine Learning
PDF
Transfer learning with Custom Vision
PDF
Practical AI for Business: Bandit Algorithms
PDF
Decision trees & random forests
PDF
Bandit Algorithms
PDF
Machine Learning Using Cloud Services
PPTX
Building single page applications
AWS Machine Learning & Google Cloud Machine Learning
Transfer learning with Custom Vision
Practical AI for Business: Bandit Algorithms
Decision trees & random forests
Bandit Algorithms
Machine Learning Using Cloud Services
Building single page applications

Recently uploaded (20)

PDF
NewMind AI Monthly Chronicles - July 2025
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PPT
Teaching material agriculture food technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Approach and Philosophy of On baking technology
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
NewMind AI Monthly Chronicles - July 2025
The Rise and Fall of 3GPP – Time for a Sabbatical?
Reach Out and Touch Someone: Haptics and Empathic Computing
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Agricultural_Statistics_at_a_Glance_2022_0.pdf
MYSQL Presentation for SQL database connectivity
Teaching material agriculture food technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Spectral efficient network and resource selection model in 5G networks
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Approach and Philosophy of On baking technology
“AI and Expert System Decision Support & Business Intelligence Systems”
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...

2013 10-02-html5-performance-aarhus