SlideShare a Scribd company logo
Bastian Grimm
Peak Ace AG
Web Performance Madness:
Critical Rendering Path Optimisation
@basgr
http://www.slideshare.net/bastiangrimm
2 pa.ag@peakaceag
No need to take notes:
https://pa.ag/brgh18spd
Because the PageSpeed Insights score is not enough!
#1 Better measurement
4 @peakaceag pa.ag
Translating experiences to performance metrics
User experience
▪ Is it happening?
› Did the navigation start successfully?
Has the server responded?
▪ Is it useful?
› Has enough content rendered for users
to engage with it?
▪ Is it usable?
› Can users interact with the page or is it
still busy loading?
▪ Is it smooth/delightful?
› Are the interactions smooth and
natural, free of lag and jank?
Corresponding metric
First Paint (FP)/First Contentful Paint (FCP)
First Meaningful Paint (FMP) -> Hero Element Timing
Time to Interactive (TTI)
Long tasks (technically the absence of those long tasks)
5 @peakaceag pa.ag
Optimising and measuring for painting timings
#1 #2
First Paint (FP)
Time to First Paint – marks the point when the
browser starts to render something, the first bit of
content on the screen.
6 @peakaceag pa.ag
Optimising and measuring for painting timings
#1 #2 #3 #4
First Paint (FP) First Contentful
Paint (FCP)
Time to First Paint – marks the point when the
browser starts to render something, the first bit of
content on the screen.
Time to First Contentful Paint – marks the point when
the browser renders the first bit of content from the
DOM, text, an image etc.
7 @peakaceag pa.ag
Optimising and measuring for painting timings
#1 #2 #3 #4 #5 #6
First Paint (FP) First Contentful
Paint (FCP)
First Meaningful
Paint (FMP) / Hero!
Time to Interactive
(TTI)
Time to First Paint – marks the point when the
browser starts to render something, the first bit of
content on the screen.
First Meaningful Paint – the paint after which the
biggest above-the-fold layout change has happened
and your most important element is visible!
8 @peakaceag pa.ag
Watching a video on YouTube? This is your hero element:
9 @peakaceag pa.ag
Chrome Dev Tools > Performance > Profiling (Frames)
10 @peakaceag pa.ag
Track paint timings with Google Analytics (in theory)
Get the tracking code snippets: http://pa.ag/2viHQSz
version 62 and up
You must ensure your
PerformanceObserver is
registered in the <head>
before any stylesheets, so it
runs before FP/FCP happens.
(a buffered flag TBD in v.2)
11 @peakaceag pa.ag
This is how it looks like in Google Analytics
Behavior > events > pages: performance metrics [first-contentful-paint]
Source: Google Analytics
12 @peakaceag pa.ag
The cool kids’ way of doing this (using GTM)
#1 #3
#2 #4
13 @peakaceag pa.ag
Combine it with Google Data Studio:
Test it: http://pa.ag/2Ee550q
The code and resources required to render the initial view of a web page
#2 Critical rendering path
15 @peakaceag pa.ag
Critical rendering path optimisation
Initial view
(critical)
Below the fold
(not critical)
Some brief, technical background:
17 @peakaceag pa.ag
CSSOM: the CSS Object Model
▪ The CSSOM is a “map” of the CSS styles
found on a web page.
▪ It’s much like the DOM (Document Object
Model), but for CSS rather than HTML.
▪ The CSSOM combined with the DOM is
used by browsers to display web pages.
body
font-size:16px;
h1
font-size:22px;
p
font-size:16px;
p
font-size:12px;
a
font-size:12px;
img
font-size:16px;
18 @peakaceag pa.ag
Web browsers use the CSSOM to render a page
If this is external CSS, the browser
needs to wait for the download
19 @peakaceag pa.ag
Google doesn’t make a single GET request for its CSS!
Because requesting external CSS is more expensive than in-lining everything.
20 @peakaceag pa.ag
How to know which CSS is critically required?
“Critical” renders in multiple resolutions & builds a combined/compressed CRP CSS:
Critical & criticalCSS on GitHub: http://pa.ag/2wJTZAu & http://pa.ag/2wT1ST9
▪ Minimum: a snapshot of CSS rules to
render a default desktop resolution
(e.g. 1280x1024).
▪ Better: various snapshots for mobile
phones, pad/s & desktop/s – manually
that’d be a lot of work!
21 @peakaceag pa.ag
If you want to play around first: Try criticalcss.com
Give it a try: http://pa.ag/2nVIwXB
22 @peakaceag pa.ag
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>CRP loading demo</title>
<!-- critical CSS goes here -->
<style> h1 { colour: green; } </style>
<!-- use async preload // no IE, Edge & some other unimportant ones (http://caniuse.com/#search=preload) -->
<link rel="preload" href="non-critical.css" as="style" onload="this.rel='stylesheet'" />
<!--noscript for req. without JS -->
<noscript><link rel="stylesheet" href="non-critical.css"></noscript>
<!-- include polyfill for shitty browsers -->
<script>
*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
(function(){ ... } ());
/*! loadCSS rel=preload polyfill. [c] 2017 Filament Group, Inc. MIT License */
(function(){ ... } ());
</script>
</head>
<body>
</body>
</html>
<!-- use async preload // no IE, Edge & some other unimportant ones
(http://caniuse.com/#search=preload) -->
<link rel="preload" href="non-critical.css" as="style" onload="this.rel='stylesheet'" />
<!-- critical CSS goes here -->
<style> h1 { colour: green; } </style>
<!-- use async preload // no IE, Edge & some other unimportant ones
(http://caniuse.com/#search=preload) -->
<link rel="preload" href="non-critical.css" as="style" onload="this.rel='stylesheet'" />
<!--noscript for req. without JS -->
<noscript><link rel="stylesheet" href="non-critical.css"></noscript>
*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
(function(){ ... } ());
/*! loadCSS rel=preload polyfill. [c] 2017 Filament Group, Inc. MIT License */
(function(){ ... } ());
Putting it all together
Fit the HTML, CSS & JS that’s necessary for “Start Render” into that first 14 kB round trip!
Inline your critical CSS.
1
Loading non-critical CSS
async using rel=“preload“.
2
Apply the CSS once it has
finished loading via “onload“.
3
Fallback for non-JS requests.
4
Implement loadCSS script for
older browsers.
5
Let’s look at an implementation…
Is it worth the effort?
24 @peakaceag pa.ag
Before & after: a fresh WordPress setup #1
HTTP, no HTTP/2, Twenty Seventeen theme (1x CSS, 8x JS, custom fonts), no caching
and no other performance optimizations
25 @peakaceag pa.ag
Before & after: a fresh WordPress setup #2
HTTP, no HTTP/2, Twenty Seventeen theme (1x CSS, 8x JS, custom fonts), W3Total (CSS,
JS, HTML minify, caching, compression)
26 @peakaceag pa.ag
Before & after: a fresh WordPress setup #3
HTTP, no HTTP/2, Twenty Seventeen theme (1x CSS, 8x JS, custom fonts), W3Total (CSS,
JS, HTML minify, caching, compression) + CRP CSS inlined
27 @peakaceag pa.ag
Performance metrics comparison at a glance
Rendering starts significantly earlier; this allows for faster interaction with the site.
KPI / MEASUREMENT
Load Time
Time to First Byte (TTFB)
Start Render
Time to Interactive (TTI)
DEFAULT WP
1.357 sec
0.454 sec
1.000 sec
0.956 sec
BASICS (W3TOTAL)
0.791 sec
0.159 sec
0.600 sec
0.931 sec
FULLY OPTIMIZED
0.789 sec
0.157 sec
0.410 sec
0.563 sec
(+32%)
(+41%)
28 @peakaceag pa.ag
TL;DR
Implement proper tracking, measure “First Meaningful Paint” (Hero Element delivery).
Audit, clean and (afterwards) split CSS into two parts: “initial view” and “below the fold”.
Use “critical” to generate and inline your critical path CSS.
Use rel=“preload“ and “loadCSS” to async load below the fold / site-wide CSS.
Off-load all overhead (JS, etc.) to stay within 14kB for faster, initial paint.
Highest quality, (more) efficient data compression & smaller files.
#3 New image formats
30 @peakaceag pa.ag
62% of all web traffic is made up of images...
… and 51% of all URLs load more than 40 images per request.
Source: http://pa.ag/1SGDOEo
Average bytes per page by content type Image requests per page
31 @peakaceag pa.ag
WebP: Google’s alternative to JPEG, PNG, and GIF
Lossy & lossless compression, transparency, metadata, colour profiles, animation, and
much smaller files (30% vs. JPEG, 80% vs. PNG) – but only in Chrome, Opera & Android
Everything about WebP: http://pa.ag/1EpFWeN / & WebP support: http://pa.ag/2FZK4XS
32 @peakaceag pa.ag
You can still use WebP with on-the-fly replacement
Swap PNG and JPEG images per re-write (i.e., using .htaccess)
VS.
33 @peakaceag pa.ag
There is way more: FLIF, BPG, JPEG-XR, etc.
If you’re “image-heavy”, go play with it!
Further reading: http://pa.ag/1S5OQmX
34 @peakaceag pa.ag
SEMrush (blog) could save 80-90% of it’s image traffic
Better compression combined with modern image formats (i.e. WebP & JPEG-XR)
35 @peakaceag pa.ag
Please DON’T use a 1.2 MB background image, Kelvin?
Seriously, this can be as small as 83 KB (PNG) or even 17 KB (WebP)!
Pretty, varied, colourful, and often very slow!
#4 Custom web fonts
37 @peakaceag pa.ag
>70% of all websites use at least one non-standard font!
Result: 114 kB of additional data and on average 3 additional HTTP requests.
Source: http://pa.ag/1BRUnbe
Font transfer size & font requests Sites with custom fonts
Font transfer size (kB) Font requests
38 @peakaceag pa.ag
Classic scenario: using external CSS
Easy to use with one big disadvantage: It’s render-blocking!
CSS (font) call to Google causes
the render to stop / block until
the download has been finished!
FOIT (flash of invisible text) or FOUT (flash of unstyled text)
can cause annoying flickering
Asynchronous?
40 @peakaceag pa.ag
Fighting the flash of unstyled text/content
Make your fall-back font match the intended web font (letter spacing, heights, etc.)
Give it a try: https://pa.ag/2qgE8EH
41 @peakaceag pa.ag
Fighting the flash of invisible text
New stuff to play around with: Various “font-display” strategies (no IE/Edge yet)
More: http://pa.ag/2eUwVob
‘font-display’ allows to display text while the font for it is still loading!
42 @peakaceag pa.ag
Don‘t miss Monica Dinculescu‘s great talk titled
„Fontastic Web Performance“
Watch the full talk: https://pa.ag/2qf6hvK
43 pa.ag@peakaceag
If you can only do one thing, I’d recommend doing this:
Go to your CSS file, look for @font-face
and add `font-display:optional` -
there hasn’t been a safer & easier gain
in #webperf in a long time!
44 pa.ag@peakaceag
We’re hiring! 25+ Performance Marketing jobs in Berlin!
Come and say “hello” or apply via jobs.pa.ag. Looking forward to speaking to you!
Always looking for talent!
Check out jobs.pa.ag
45 @peakaceag pa.ag
http://pa.ag/brgh18spd
Always looking for talent! Check out jobs.pa.ag
Bastian Grimm
bg@pa.ag
twitter.com/peakaceag
facebook.com/peakaceag
www.pa.ag
Liked the deck? Here you go:

More Related Content

PDF
Super speed around the globe - SearchLeeds 2018
PDF
The need for Speed: Advanced #webperf - SEOday 2018
PDF
Technical SEO vs. User Experience - Bastian Grimm, Peak Ace AG
PDF
Sabine Langmann - Brighton SEO 2018 - How to expand to different markets
PDF
Guide To Web Development
PDF
Migration Best Practices - SMX London 2018
PDF
Migration Best-Practices: Successfully re-launching your website - SMX New Yo...
PPTX
How webpage loading takes place?
Super speed around the globe - SearchLeeds 2018
The need for Speed: Advanced #webperf - SEOday 2018
Technical SEO vs. User Experience - Bastian Grimm, Peak Ace AG
Sabine Langmann - Brighton SEO 2018 - How to expand to different markets
Guide To Web Development
Migration Best Practices - SMX London 2018
Migration Best-Practices: Successfully re-launching your website - SMX New Yo...
How webpage loading takes place?

What's hot (20)

PDF
Migration Best Practices - SEOkomm 2018
PDF
How fast is fast enough - SMX West 2018
PDF
Migration Best Practices - SMX West 2019
PDF
Welcome to a new reality - DeepCrawl Webinar 2018
PDF
Migration Best Practices - Search Y 2019, Paris
PDF
International Site Speed Tweaks - ISS 2017 Barcelona
PDF
AMP - SMX München 2018
PDF
Whats Next in SEO & CRO - 3XE Conference 2018 Dublin
PDF
HPEC 2021 grblas
PDF
OK Google, Whats next? - OMT Wiesbaden 2018
PPTX
Migration Best Practices - Peak Ace on Air
PDF
SearchLeeds 2018 - Bastian Grimm - Peak Ace - International site speed: Going...
PDF
The Need for Speed (5 Performance Optimization Tipps) - brightonSEO 2014
PPTX
Three site speed optimisation tips to make your website REALLY fast - Brighto...
PDF
Advanced data-driven technical SEO - SMX London 2019
PPTX
Rendering SEO (explained by Google's Martin Splitt)
PPTX
DeepCrawl Webinar: Performing SEO on the Edge
PPTX
SearchLove San Diego 2018 | Mat Clayton | Site Speed for Digital Marketers
PDF
TechSEO Boost 2018: Implementing Hreflang on Legacy Tech Stacks Using Service...
PDF
Introduction core web vitals
Migration Best Practices - SEOkomm 2018
How fast is fast enough - SMX West 2018
Migration Best Practices - SMX West 2019
Welcome to a new reality - DeepCrawl Webinar 2018
Migration Best Practices - Search Y 2019, Paris
International Site Speed Tweaks - ISS 2017 Barcelona
AMP - SMX München 2018
Whats Next in SEO & CRO - 3XE Conference 2018 Dublin
HPEC 2021 grblas
OK Google, Whats next? - OMT Wiesbaden 2018
Migration Best Practices - Peak Ace on Air
SearchLeeds 2018 - Bastian Grimm - Peak Ace - International site speed: Going...
The Need for Speed (5 Performance Optimization Tipps) - brightonSEO 2014
Three site speed optimisation tips to make your website REALLY fast - Brighto...
Advanced data-driven technical SEO - SMX London 2019
Rendering SEO (explained by Google's Martin Splitt)
DeepCrawl Webinar: Performing SEO on the Edge
SearchLove San Diego 2018 | Mat Clayton | Site Speed for Digital Marketers
TechSEO Boost 2018: Implementing Hreflang on Legacy Tech Stacks Using Service...
Introduction core web vitals
Ad

Similar to Web Performance Madness - brightonSEO 2018 (20)

PDF
The latest in site speed: advanced #webperf 2018
PPT
Front-end performances
PDF
Profiling PHP with Xdebug / Webgrind
KEY
Intro To Django
PPTX
Front end optimization
PPTX
Building high performing web pages
PDF
フロントエンドエンジニア(仮) 〜え、ちょっとフロントやること多すぎじゃない!?〜
PPT
腾讯大讲堂09 如何建设高性能网站
PPT
腾讯大讲堂09 如何建设高性能网站
PDF
Complete SEO Report with checklist required
PPSX
Magento performancenbs
PDF
Performance as UX with Justin Howlett
PDF
7 Habits of Exceptional Performance
PPTX
Web Optimisation
PPTX
Ie9 dev overview (300) beta
PPTX
The Need for Speed - SMX Sydney 2013
PPTX
Web Performance: 3 Stages to Success
PDF
PAC 2019 virtual Mark Tomlinson
PPTX
Troubleshooting SEO for JS Frameworks - Patrick Stox - DTD 2018
ODP
A Holistic View of Website Performance
The latest in site speed: advanced #webperf 2018
Front-end performances
Profiling PHP with Xdebug / Webgrind
Intro To Django
Front end optimization
Building high performing web pages
フロントエンドエンジニア(仮) 〜え、ちょっとフロントやること多すぎじゃない!?〜
腾讯大讲堂09 如何建设高性能网站
腾讯大讲堂09 如何建设高性能网站
Complete SEO Report with checklist required
Magento performancenbs
Performance as UX with Justin Howlett
7 Habits of Exceptional Performance
Web Optimisation
Ie9 dev overview (300) beta
The Need for Speed - SMX Sydney 2013
Web Performance: 3 Stages to Success
PAC 2019 virtual Mark Tomlinson
Troubleshooting SEO for JS Frameworks - Patrick Stox - DTD 2018
A Holistic View of Website Performance
Ad

More from Bastian Grimm (13)

PDF
SEOday Köln 2020 - Surprise, Surprise - 5 SEO secrets
PDF
Data-driven Technical SEO: Logfile Auditing - SEOkomm 2018
PDF
Digitale Assistenzsysteme - SMX München 2018
PDF
Migration Best-Practices: So gelingt der erfolgreiche Relaunch - SEOkomm 2017
PDF
Digitale Assistenten - OMX 2017
PDF
Welcome to a New Reality - SEO goes Mobile First in 2017
PPTX
Welcome to a New Reality - SEO goes Mobile First in 2017
PPTX
HTTPs Migration How To - SMX München 2017
PPTX
Keyword Strategie: Do's & Don'ts bei der Keyword Recherche - SMX München 2017
PPTX
Technical SEO: 2017 Edition - SEO & Love Verona 2017
PPTX
Quo Vadis SEO (Die Zukunft des SEO) - SEOkomm Salzburg 2016
PDF
Technical SEO: 2016 Edition - SEODAY 2016
PDF
Crawl Budget Best Practices - SEODAY 2016
SEOday Köln 2020 - Surprise, Surprise - 5 SEO secrets
Data-driven Technical SEO: Logfile Auditing - SEOkomm 2018
Digitale Assistenzsysteme - SMX München 2018
Migration Best-Practices: So gelingt der erfolgreiche Relaunch - SEOkomm 2017
Digitale Assistenten - OMX 2017
Welcome to a New Reality - SEO goes Mobile First in 2017
Welcome to a New Reality - SEO goes Mobile First in 2017
HTTPs Migration How To - SMX München 2017
Keyword Strategie: Do's & Don'ts bei der Keyword Recherche - SMX München 2017
Technical SEO: 2017 Edition - SEO & Love Verona 2017
Quo Vadis SEO (Die Zukunft des SEO) - SEOkomm Salzburg 2016
Technical SEO: 2016 Edition - SEODAY 2016
Crawl Budget Best Practices - SEODAY 2016

Recently uploaded (20)

PPTX
Cloud computing and distributed systems.
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Modernizing your data center with Dell and AMD
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
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Big Data Technologies - Introduction.pptx
PDF
cuic standard and advanced reporting.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
KodekX | Application Modernization Development
PDF
Chapter 3 Spatial Domain Image Processing.pdf
Cloud computing and distributed systems.
Unlocking AI with Model Context Protocol (MCP)
Digital-Transformation-Roadmap-for-Companies.pptx
Encapsulation_ Review paper, used for researhc scholars
NewMind AI Weekly Chronicles - August'25 Week I
Modernizing your data center with Dell and AMD
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Diabetes mellitus diagnosis method based random forest with bat algorithm
“AI and Expert System Decision Support & Business Intelligence Systems”
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Big Data Technologies - Introduction.pptx
cuic standard and advanced reporting.pdf
A Presentation on Artificial Intelligence
Reach Out and Touch Someone: Haptics and Empathic Computing
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
KodekX | Application Modernization Development
Chapter 3 Spatial Domain Image Processing.pdf

Web Performance Madness - brightonSEO 2018

  • 1. Bastian Grimm Peak Ace AG Web Performance Madness: Critical Rendering Path Optimisation @basgr http://www.slideshare.net/bastiangrimm
  • 2. 2 pa.ag@peakaceag No need to take notes: https://pa.ag/brgh18spd
  • 3. Because the PageSpeed Insights score is not enough! #1 Better measurement
  • 4. 4 @peakaceag pa.ag Translating experiences to performance metrics User experience ▪ Is it happening? › Did the navigation start successfully? Has the server responded? ▪ Is it useful? › Has enough content rendered for users to engage with it? ▪ Is it usable? › Can users interact with the page or is it still busy loading? ▪ Is it smooth/delightful? › Are the interactions smooth and natural, free of lag and jank? Corresponding metric First Paint (FP)/First Contentful Paint (FCP) First Meaningful Paint (FMP) -> Hero Element Timing Time to Interactive (TTI) Long tasks (technically the absence of those long tasks)
  • 5. 5 @peakaceag pa.ag Optimising and measuring for painting timings #1 #2 First Paint (FP) Time to First Paint – marks the point when the browser starts to render something, the first bit of content on the screen.
  • 6. 6 @peakaceag pa.ag Optimising and measuring for painting timings #1 #2 #3 #4 First Paint (FP) First Contentful Paint (FCP) Time to First Paint – marks the point when the browser starts to render something, the first bit of content on the screen. Time to First Contentful Paint – marks the point when the browser renders the first bit of content from the DOM, text, an image etc.
  • 7. 7 @peakaceag pa.ag Optimising and measuring for painting timings #1 #2 #3 #4 #5 #6 First Paint (FP) First Contentful Paint (FCP) First Meaningful Paint (FMP) / Hero! Time to Interactive (TTI) Time to First Paint – marks the point when the browser starts to render something, the first bit of content on the screen. First Meaningful Paint – the paint after which the biggest above-the-fold layout change has happened and your most important element is visible!
  • 8. 8 @peakaceag pa.ag Watching a video on YouTube? This is your hero element:
  • 9. 9 @peakaceag pa.ag Chrome Dev Tools > Performance > Profiling (Frames)
  • 10. 10 @peakaceag pa.ag Track paint timings with Google Analytics (in theory) Get the tracking code snippets: http://pa.ag/2viHQSz version 62 and up You must ensure your PerformanceObserver is registered in the <head> before any stylesheets, so it runs before FP/FCP happens. (a buffered flag TBD in v.2)
  • 11. 11 @peakaceag pa.ag This is how it looks like in Google Analytics Behavior > events > pages: performance metrics [first-contentful-paint] Source: Google Analytics
  • 12. 12 @peakaceag pa.ag The cool kids’ way of doing this (using GTM) #1 #3 #2 #4
  • 13. 13 @peakaceag pa.ag Combine it with Google Data Studio: Test it: http://pa.ag/2Ee550q
  • 14. The code and resources required to render the initial view of a web page #2 Critical rendering path
  • 15. 15 @peakaceag pa.ag Critical rendering path optimisation Initial view (critical) Below the fold (not critical)
  • 16. Some brief, technical background:
  • 17. 17 @peakaceag pa.ag CSSOM: the CSS Object Model ▪ The CSSOM is a “map” of the CSS styles found on a web page. ▪ It’s much like the DOM (Document Object Model), but for CSS rather than HTML. ▪ The CSSOM combined with the DOM is used by browsers to display web pages. body font-size:16px; h1 font-size:22px; p font-size:16px; p font-size:12px; a font-size:12px; img font-size:16px;
  • 18. 18 @peakaceag pa.ag Web browsers use the CSSOM to render a page If this is external CSS, the browser needs to wait for the download
  • 19. 19 @peakaceag pa.ag Google doesn’t make a single GET request for its CSS! Because requesting external CSS is more expensive than in-lining everything.
  • 20. 20 @peakaceag pa.ag How to know which CSS is critically required? “Critical” renders in multiple resolutions & builds a combined/compressed CRP CSS: Critical & criticalCSS on GitHub: http://pa.ag/2wJTZAu & http://pa.ag/2wT1ST9 ▪ Minimum: a snapshot of CSS rules to render a default desktop resolution (e.g. 1280x1024). ▪ Better: various snapshots for mobile phones, pad/s & desktop/s – manually that’d be a lot of work!
  • 21. 21 @peakaceag pa.ag If you want to play around first: Try criticalcss.com Give it a try: http://pa.ag/2nVIwXB
  • 22. 22 @peakaceag pa.ag <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>CRP loading demo</title> <!-- critical CSS goes here --> <style> h1 { colour: green; } </style> <!-- use async preload // no IE, Edge & some other unimportant ones (http://caniuse.com/#search=preload) --> <link rel="preload" href="non-critical.css" as="style" onload="this.rel='stylesheet'" /> <!--noscript for req. without JS --> <noscript><link rel="stylesheet" href="non-critical.css"></noscript> <!-- include polyfill for shitty browsers --> <script> *! loadCSS. [c]2017 Filament Group, Inc. MIT License */ (function(){ ... } ()); /*! loadCSS rel=preload polyfill. [c] 2017 Filament Group, Inc. MIT License */ (function(){ ... } ()); </script> </head> <body> </body> </html> <!-- use async preload // no IE, Edge & some other unimportant ones (http://caniuse.com/#search=preload) --> <link rel="preload" href="non-critical.css" as="style" onload="this.rel='stylesheet'" /> <!-- critical CSS goes here --> <style> h1 { colour: green; } </style> <!-- use async preload // no IE, Edge & some other unimportant ones (http://caniuse.com/#search=preload) --> <link rel="preload" href="non-critical.css" as="style" onload="this.rel='stylesheet'" /> <!--noscript for req. without JS --> <noscript><link rel="stylesheet" href="non-critical.css"></noscript> *! loadCSS. [c]2017 Filament Group, Inc. MIT License */ (function(){ ... } ()); /*! loadCSS rel=preload polyfill. [c] 2017 Filament Group, Inc. MIT License */ (function(){ ... } ()); Putting it all together Fit the HTML, CSS & JS that’s necessary for “Start Render” into that first 14 kB round trip! Inline your critical CSS. 1 Loading non-critical CSS async using rel=“preload“. 2 Apply the CSS once it has finished loading via “onload“. 3 Fallback for non-JS requests. 4 Implement loadCSS script for older browsers. 5
  • 23. Let’s look at an implementation… Is it worth the effort?
  • 24. 24 @peakaceag pa.ag Before & after: a fresh WordPress setup #1 HTTP, no HTTP/2, Twenty Seventeen theme (1x CSS, 8x JS, custom fonts), no caching and no other performance optimizations
  • 25. 25 @peakaceag pa.ag Before & after: a fresh WordPress setup #2 HTTP, no HTTP/2, Twenty Seventeen theme (1x CSS, 8x JS, custom fonts), W3Total (CSS, JS, HTML minify, caching, compression)
  • 26. 26 @peakaceag pa.ag Before & after: a fresh WordPress setup #3 HTTP, no HTTP/2, Twenty Seventeen theme (1x CSS, 8x JS, custom fonts), W3Total (CSS, JS, HTML minify, caching, compression) + CRP CSS inlined
  • 27. 27 @peakaceag pa.ag Performance metrics comparison at a glance Rendering starts significantly earlier; this allows for faster interaction with the site. KPI / MEASUREMENT Load Time Time to First Byte (TTFB) Start Render Time to Interactive (TTI) DEFAULT WP 1.357 sec 0.454 sec 1.000 sec 0.956 sec BASICS (W3TOTAL) 0.791 sec 0.159 sec 0.600 sec 0.931 sec FULLY OPTIMIZED 0.789 sec 0.157 sec 0.410 sec 0.563 sec (+32%) (+41%)
  • 28. 28 @peakaceag pa.ag TL;DR Implement proper tracking, measure “First Meaningful Paint” (Hero Element delivery). Audit, clean and (afterwards) split CSS into two parts: “initial view” and “below the fold”. Use “critical” to generate and inline your critical path CSS. Use rel=“preload“ and “loadCSS” to async load below the fold / site-wide CSS. Off-load all overhead (JS, etc.) to stay within 14kB for faster, initial paint.
  • 29. Highest quality, (more) efficient data compression & smaller files. #3 New image formats
  • 30. 30 @peakaceag pa.ag 62% of all web traffic is made up of images... … and 51% of all URLs load more than 40 images per request. Source: http://pa.ag/1SGDOEo Average bytes per page by content type Image requests per page
  • 31. 31 @peakaceag pa.ag WebP: Google’s alternative to JPEG, PNG, and GIF Lossy & lossless compression, transparency, metadata, colour profiles, animation, and much smaller files (30% vs. JPEG, 80% vs. PNG) – but only in Chrome, Opera & Android Everything about WebP: http://pa.ag/1EpFWeN / & WebP support: http://pa.ag/2FZK4XS
  • 32. 32 @peakaceag pa.ag You can still use WebP with on-the-fly replacement Swap PNG and JPEG images per re-write (i.e., using .htaccess) VS.
  • 33. 33 @peakaceag pa.ag There is way more: FLIF, BPG, JPEG-XR, etc. If you’re “image-heavy”, go play with it! Further reading: http://pa.ag/1S5OQmX
  • 34. 34 @peakaceag pa.ag SEMrush (blog) could save 80-90% of it’s image traffic Better compression combined with modern image formats (i.e. WebP & JPEG-XR)
  • 35. 35 @peakaceag pa.ag Please DON’T use a 1.2 MB background image, Kelvin? Seriously, this can be as small as 83 KB (PNG) or even 17 KB (WebP)!
  • 36. Pretty, varied, colourful, and often very slow! #4 Custom web fonts
  • 37. 37 @peakaceag pa.ag >70% of all websites use at least one non-standard font! Result: 114 kB of additional data and on average 3 additional HTTP requests. Source: http://pa.ag/1BRUnbe Font transfer size & font requests Sites with custom fonts Font transfer size (kB) Font requests
  • 38. 38 @peakaceag pa.ag Classic scenario: using external CSS Easy to use with one big disadvantage: It’s render-blocking! CSS (font) call to Google causes the render to stop / block until the download has been finished!
  • 39. FOIT (flash of invisible text) or FOUT (flash of unstyled text) can cause annoying flickering Asynchronous?
  • 40. 40 @peakaceag pa.ag Fighting the flash of unstyled text/content Make your fall-back font match the intended web font (letter spacing, heights, etc.) Give it a try: https://pa.ag/2qgE8EH
  • 41. 41 @peakaceag pa.ag Fighting the flash of invisible text New stuff to play around with: Various “font-display” strategies (no IE/Edge yet) More: http://pa.ag/2eUwVob ‘font-display’ allows to display text while the font for it is still loading!
  • 42. 42 @peakaceag pa.ag Don‘t miss Monica Dinculescu‘s great talk titled „Fontastic Web Performance“ Watch the full talk: https://pa.ag/2qf6hvK
  • 43. 43 pa.ag@peakaceag If you can only do one thing, I’d recommend doing this: Go to your CSS file, look for @font-face and add `font-display:optional` - there hasn’t been a safer & easier gain in #webperf in a long time!
  • 44. 44 pa.ag@peakaceag We’re hiring! 25+ Performance Marketing jobs in Berlin! Come and say “hello” or apply via jobs.pa.ag. Looking forward to speaking to you! Always looking for talent! Check out jobs.pa.ag
  • 45. 45 @peakaceag pa.ag http://pa.ag/brgh18spd Always looking for talent! Check out jobs.pa.ag Bastian Grimm bg@pa.ag twitter.com/peakaceag facebook.com/peakaceag www.pa.ag Liked the deck? Here you go: