SlideShare a Scribd company logo
1 of 22
Download to read offline
Ilya Grigorik - @igrigorik
igrigorik@google.com
Preconnect, prefetch, prerender ...
aka, building a web performance oracle in your application!
@igrigorikblink-dev thread
Top 1M Alexa sites...
● Cable profile (5Mbps / 28 ms RTT)
● Main thread attribution in Blink
○ Measured via Telemetry
● 69.5% of time blocked on network
● 6.6% of time blocked JavaScript
● 5.1% blocked on Layout
● 4.5% blocked on Paint
● ...
● No surprise here (hopefully)
○ First page load is network bound
○ First page load is latency bound
Our pages consist of dozens of assets
Primer on Web Performance (Chapter 10)
… (snip 30 requests) ...
● 52 requests
● 4+ seconds
Huh?
@igrigorik
Speed, performance and human perception
“Connection view” tells the story...
● 30 connections
○ DNS lookups
○ TCP handshakes
○ …
● Blue: download time
@igrigorik
We’re not BW limited,
we’re literally idling,
waiting on the network
to deliver resources.
Let’s build a smarter browser!
We can hide some of the network latency through clever tricks.
The pre-* party...
Primer on Web Performance (Chapter 10) @igrigorik
Preresolve
Preconnect
Prefetch
Prerender
@igrigorik
Pre-resolve DNS names on browser startup...
● Scenario: when you load the browser first
thing in the morning (or after restart), where
do you usually head?
● Let’s pre-resolve all of the popular names!
○ Chrome resolves top 10 destinations.
Head to chrome://dns/ to see your list.
High Performance Networking in Google Chrome
@igrigorik
Preresolve is cute, but does it help much?
● How fast is your local DNS?
Chrome knows the answer...
chrome://histograms/DNS
● Good case: < 30 ms
● Average: 30-100 ms
● Ouch: 100 ms+
High Performance Networking in Google Chrome
@igrigorik
Let’s predict where you’re heading next...
If you type in “ama” what’s the likelihood you’re heading to Amazon?
● Chrome tracks the hit / miss count, and uses it to initiate DNS preresolve and TCP preconnect!
● High confidence hits may trigger a full prerender in a background tab.
● Head to chrome://predictors/ to see your list.
High Performance Networking in Google Chrome
@igrigorik
Hmm, pre-rendering you say? Tell me more...
High Performance Networking in Google Chrome
● Head to chrome://net-internals/#prerender
● Try it yourself via prerender-test.appspot.com.
@igrigorik
Instant Pages *is* Chrome Prerendering!
High Performance Networking in Google Chrome
@igrigorik
Could we optimize repeat visits further? Why, yes!
High Performance Networking in Google Chrome
● Remember subresource hostnames + track stats on pre{connect, resolve} rates
● Use above information on future navigations to initiate appropriate actions...
Check your own site: chrome://dns
@igrigorik
Can we discover critical resources quicker? Yep...
Chrome preloader
Chrome’s preloader delivers a
~20% speed improvement!
● Blocking resources block DOM construction...
● Preload scanner “looks ahead” in the HTML document to identify critical resources
○ JavaScript, CSS, etc.
Don’t hide your resources from the preload scanner! E.g. JS loaders, polyfills, etc.
“We were using XHR to download CSS... When it came it our
attention that XHRs are requested at low priority we decided to run
an experiment to see its impact on G+ latency (vs using declarative
markup like <link>).
In SPDY capable browsers it (using <link>) resulted in a big latency
improvement. In Chrome 27 we saw a 4x speedup at the median,
and 5x at 25th percentile. In Firefox 21 we saw a 5x speedup at
median, and 8x at 25th percentile.”
Shubhie Panicker - G+ Front-end Team
In short, Chrome does a lot!
but you can help it…
Speed is a feature (Chapter 1) @igrigorik
The browser is trying to predict and
anticipate user activity, but you have the
app-specific insights - leverage them!
1. Pre-resolve DNS hostnames
2. Mark critical subresources (don’t hide them!)
3. Prefetch critical resources
4. Prerender where applicable
@igrigorik
Embed “dns-prefetch” hints...
Embed prefetch hints in <head> to hint the browser to pre-resolve these names.
● Useful for critical resources later in the page
● Useful for resources behind a redirect
○ host1.com/resource > 301 > host2.com/resouce
■ dns-prefetch: host2.com
○ (or even better, eliminate the redirect :))
<link rel="dns-prefetch" href="hostname_to_resolve.com">
<link rel="dns-prefetch" href="host2.com">
High Performance Networking in Google Chrome
@igrigorik
Embed “subresource” hints...
Embed subresource hints in <head> to initiate immediate fetch for current page!
● Subresource hint identifies critical resources required for current page load.
● Place subresource hints as early as possible.
○ In a way, this is a “manual preload scanner” strategy ...
<link rel="subresource" href="critical/app.js">
<link rel="subresource" href="critical/style.css">
High Performance Networking in Google Chrome
@igrigorik
Embed “prefetch” hints...
Embed prefetch hints in <head> to initiate deferred fetch for later navigation.
● Prefetch hint identifies resources that may be needed in future navigation.
● Prefetch hints have lowest possible priority.
● Prefetch hints are content agnostic: fetch asset, place in cache.
○ You do have cache headers enabled, right? Right?
<link rel="prefetch" href="checkout.html">
<link rel="prefetch" href="other-styles.css">
High Performance Networking in Google Chrome
@igrigorik
Embed “prerender” hints...
Embed prerender hints in <head> to initiate background prerender of entire page!
● The page is fetch, and all of its assets!
● Use Page Visibility API to defer JS actions until page is visible.
○ Analytics beacons (GA does this already), custom code, etc.
● Only “safe” pages can be prerendered (aka, GET).
● Prerendering is resource heavy - use with caution.
<link rel="prerender" href="checkout.html">
High Performance Networking in Google Chrome
Predict, measure, optimize… iterate.
You can inject each of the hints when the page is generated
○ You know the structure of the page / application, use it...
○ Run offline log analysis (e.g. step_a.html > step_b.html)
You can inject hints “at runtime” based on user interactions!
○ Via the magic of JavaScript, simply add the appropriate link tag:
var hint = document.createElement("link")
hint.setAttribute("rel", "prerender")
hint.setAttribute("href", "next-page.html")
document.getElementsByTagName("head")[0].appendChild(hint)
P.S. If the hint is no longer relevant, reverse works also.. nuke it from the DOM!
Twitter igrigorik
Email igrigorik@google.com
Web igvita.com
TL;DR
1. <link rel="dns-prefetch" href="hostname_to_resolve.com">
a. Pre-resolve DNS hostnames for assets later in the page! (Most browsers)
2. <link rel="subresource" href="/javascript/myapp.js">
a. Initiate early resource fetch for current navigation (Chrome only)
3. <link rel="prefetch" href="/images/big.jpeg">
a. Prefetch asset for a future navigation, place in cache… (Most browsers)
4. <link rel="prerender" href="//example.org/next_page.html">
a. Prerender page in background tab for future navigation
● Slides @ bit.ly/1bUFCsI
● Checkout Steve’s prebrowsing slides!

More Related Content

What's hot

Stefan Judis "Did we(b development) lose the right direction?"
Stefan Judis "Did we(b development) lose the right direction?"Stefan Judis "Did we(b development) lose the right direction?"
Stefan Judis "Did we(b development) lose the right direction?"Fwdays
 
State of the resource timing api
State of the resource timing apiState of the resource timing api
State of the resource timing apiAaron Peters
 
High Performance Web Components
High Performance Web ComponentsHigh Performance Web Components
High Performance Web ComponentsSteve Souders
 
Fast Loading JavaScript
Fast Loading JavaScriptFast Loading JavaScript
Fast Loading JavaScriptAaron Peters
 
Accelerated Mobile - Beyond AMP
Accelerated Mobile - Beyond AMPAccelerated Mobile - Beyond AMP
Accelerated Mobile - Beyond AMPJono Alderson
 
Mobile Web Speed Bumps
Mobile Web Speed BumpsMobile Web Speed Bumps
Mobile Web Speed BumpsNicholas Zakas
 
How fast are we going now?
How fast are we going now?How fast are we going now?
How fast are we going now?Steve Souders
 
Hardening WordPress - Friends of Search 2014 (WordPress Security)
Hardening WordPress - Friends of Search 2014 (WordPress Security)Hardening WordPress - Friends of Search 2014 (WordPress Security)
Hardening WordPress - Friends of Search 2014 (WordPress Security)Bastian Grimm
 
Browser Wars Episode 1: The Phantom Menace
Browser Wars Episode 1: The Phantom MenaceBrowser Wars Episode 1: The Phantom Menace
Browser Wars Episode 1: The Phantom MenaceNicholas Zakas
 
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)Bastian Grimm
 
Real World Web Standards
Real World Web StandardsReal World Web Standards
Real World Web Standardsgleddy
 
Web Page Test - Beyond the Basics
Web Page Test - Beyond the BasicsWeb Page Test - Beyond the Basics
Web Page Test - Beyond the BasicsAndy Davies
 
Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)Nicholas Zakas
 
Plugins at WordCamp Phoenix
Plugins at WordCamp PhoenixPlugins at WordCamp Phoenix
Plugins at WordCamp PhoenixAndrew Ryno
 
Technical SEO: Crawl Space Management - SEOZone Istanbul 2014
Technical SEO: Crawl Space Management - SEOZone Istanbul 2014Technical SEO: Crawl Space Management - SEOZone Istanbul 2014
Technical SEO: Crawl Space Management - SEOZone Istanbul 2014Bastian Grimm
 
Widget Summit 2008
Widget Summit 2008Widget Summit 2008
Widget Summit 2008Volkan Unsal
 
Web Performance Optimierung - DWX13
Web Performance Optimierung - DWX13Web Performance Optimierung - DWX13
Web Performance Optimierung - DWX13Walter Ebert
 
[wvbcn] Adaptive Images in Responsive Web Design
[wvbcn] Adaptive Images in Responsive Web Design[wvbcn] Adaptive Images in Responsive Web Design
[wvbcn] Adaptive Images in Responsive Web DesignChristopher Schmitt
 
40 WordPress Tips: Security, Engagement, SEO & Performance - SMX Sydney 2013
40 WordPress Tips: Security, Engagement, SEO & Performance - SMX Sydney 201340 WordPress Tips: Security, Engagement, SEO & Performance - SMX Sydney 2013
40 WordPress Tips: Security, Engagement, SEO & Performance - SMX Sydney 2013Bastian Grimm
 

What's hot (20)

do u webview?
do u webview?do u webview?
do u webview?
 
Stefan Judis "Did we(b development) lose the right direction?"
Stefan Judis "Did we(b development) lose the right direction?"Stefan Judis "Did we(b development) lose the right direction?"
Stefan Judis "Did we(b development) lose the right direction?"
 
State of the resource timing api
State of the resource timing apiState of the resource timing api
State of the resource timing api
 
High Performance Web Components
High Performance Web ComponentsHigh Performance Web Components
High Performance Web Components
 
Fast Loading JavaScript
Fast Loading JavaScriptFast Loading JavaScript
Fast Loading JavaScript
 
Accelerated Mobile - Beyond AMP
Accelerated Mobile - Beyond AMPAccelerated Mobile - Beyond AMP
Accelerated Mobile - Beyond AMP
 
Mobile Web Speed Bumps
Mobile Web Speed BumpsMobile Web Speed Bumps
Mobile Web Speed Bumps
 
How fast are we going now?
How fast are we going now?How fast are we going now?
How fast are we going now?
 
Hardening WordPress - Friends of Search 2014 (WordPress Security)
Hardening WordPress - Friends of Search 2014 (WordPress Security)Hardening WordPress - Friends of Search 2014 (WordPress Security)
Hardening WordPress - Friends of Search 2014 (WordPress Security)
 
Browser Wars Episode 1: The Phantom Menace
Browser Wars Episode 1: The Phantom MenaceBrowser Wars Episode 1: The Phantom Menace
Browser Wars Episode 1: The Phantom Menace
 
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
Hardening WordPress - SAScon Manchester 2013 (WordPress Security)
 
Real World Web Standards
Real World Web StandardsReal World Web Standards
Real World Web Standards
 
Web Page Test - Beyond the Basics
Web Page Test - Beyond the BasicsWeb Page Test - Beyond the Basics
Web Page Test - Beyond the Basics
 
Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)
 
Plugins at WordCamp Phoenix
Plugins at WordCamp PhoenixPlugins at WordCamp Phoenix
Plugins at WordCamp Phoenix
 
Technical SEO: Crawl Space Management - SEOZone Istanbul 2014
Technical SEO: Crawl Space Management - SEOZone Istanbul 2014Technical SEO: Crawl Space Management - SEOZone Istanbul 2014
Technical SEO: Crawl Space Management - SEOZone Istanbul 2014
 
Widget Summit 2008
Widget Summit 2008Widget Summit 2008
Widget Summit 2008
 
Web Performance Optimierung - DWX13
Web Performance Optimierung - DWX13Web Performance Optimierung - DWX13
Web Performance Optimierung - DWX13
 
[wvbcn] Adaptive Images in Responsive Web Design
[wvbcn] Adaptive Images in Responsive Web Design[wvbcn] Adaptive Images in Responsive Web Design
[wvbcn] Adaptive Images in Responsive Web Design
 
40 WordPress Tips: Security, Engagement, SEO & Performance - SMX Sydney 2013
40 WordPress Tips: Security, Engagement, SEO & Performance - SMX Sydney 201340 WordPress Tips: Security, Engagement, SEO & Performance - SMX Sydney 2013
40 WordPress Tips: Security, Engagement, SEO & Performance - SMX Sydney 2013
 

Similar to Ilya Grigorik on Preconnect, Prefetch, Prerender for Faster Page Loads

PrairieDevCon 2014 - Web Doesn't Mean Slow
PrairieDevCon 2014 -  Web Doesn't Mean SlowPrairieDevCon 2014 -  Web Doesn't Mean Slow
PrairieDevCon 2014 - Web Doesn't Mean Slowdmethvin
 
Optimising Web Application Frontend
Optimising Web Application FrontendOptimising Web Application Frontend
Optimising Web Application Frontendtkramar
 
implement lighthouse-ci with your web development workflow
implement lighthouse-ci with your web development workflowimplement lighthouse-ci with your web development workflow
implement lighthouse-ci with your web development workflowWordPress
 
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...Horacio Gonzalez
 
Drupalcamp performance
Drupalcamp performanceDrupalcamp performance
Drupalcamp performanceFrontkom
 
Web Performance Madness - brightonSEO 2018
Web Performance Madness - brightonSEO 2018Web Performance Madness - brightonSEO 2018
Web Performance Madness - brightonSEO 2018Bastian Grimm
 
20 tips for website performance
20 tips for website performance20 tips for website performance
20 tips for website performanceAndrew Siemer
 
jQuery Conference San Diego 2014 - Web Performance
jQuery Conference San Diego 2014 - Web PerformancejQuery Conference San Diego 2014 - Web Performance
jQuery Conference San Diego 2014 - Web Performancedmethvin
 
Ten practical ways to improve front-end performance
Ten practical ways to improve front-end performanceTen practical ways to improve front-end performance
Ten practical ways to improve front-end performanceAndrew Rota
 
Word press optimizations
Word press optimizations Word press optimizations
Word press optimizations Shawn DeWolfe
 
Website & Internet + Performance testing
Website & Internet + Performance testingWebsite & Internet + Performance testing
Website & Internet + Performance testingRoman Ananev
 
Security and why you need to review yours.
Security and why you need to review yours.Security and why you need to review yours.
Security and why you need to review yours.David Busby, CISSP
 
Troubleshooting SEO for JS Frameworks - Patrick Stox - DTD 2018
Troubleshooting SEO for JS Frameworks - Patrick Stox - DTD 2018Troubleshooting SEO for JS Frameworks - Patrick Stox - DTD 2018
Troubleshooting SEO for JS Frameworks - Patrick Stox - DTD 2018patrickstox
 
Navigating the critical rendering path - Jamie Alberico - VirtuaCon
Navigating the critical rendering path -  Jamie Alberico - VirtuaConNavigating the critical rendering path -  Jamie Alberico - VirtuaCon
Navigating the critical rendering path - Jamie Alberico - VirtuaConJamie Indigo
 
Web performance mercadolibre - ECI 2013
Web performance   mercadolibre - ECI 2013Web performance   mercadolibre - ECI 2013
Web performance mercadolibre - ECI 2013Santiago Aimetta
 
Optimizing your WordPress website
Optimizing your WordPress websiteOptimizing your WordPress website
Optimizing your WordPress websitemwfordesigns
 
7 Habits of Exceptional Performance
7 Habits of Exceptional Performance7 Habits of Exceptional Performance
7 Habits of Exceptional PerformanceNicole Sullivan
 
The need for Speed: Advanced #webperf - SEOday 2018
The need for Speed: Advanced #webperf - SEOday 2018The need for Speed: Advanced #webperf - SEOday 2018
The need for Speed: Advanced #webperf - SEOday 2018Bastian Grimm
 

Similar to Ilya Grigorik on Preconnect, Prefetch, Prerender for Faster Page Loads (20)

Frontend SPOF
Frontend SPOFFrontend SPOF
Frontend SPOF
 
PrairieDevCon 2014 - Web Doesn't Mean Slow
PrairieDevCon 2014 -  Web Doesn't Mean SlowPrairieDevCon 2014 -  Web Doesn't Mean Slow
PrairieDevCon 2014 - Web Doesn't Mean Slow
 
Optimising Web Application Frontend
Optimising Web Application FrontendOptimising Web Application Frontend
Optimising Web Application Frontend
 
implement lighthouse-ci with your web development workflow
implement lighthouse-ci with your web development workflowimplement lighthouse-ci with your web development workflow
implement lighthouse-ci with your web development workflow
 
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
 
Drupalcamp performance
Drupalcamp performanceDrupalcamp performance
Drupalcamp performance
 
Web Performance Madness - brightonSEO 2018
Web Performance Madness - brightonSEO 2018Web Performance Madness - brightonSEO 2018
Web Performance Madness - brightonSEO 2018
 
20 tips for website performance
20 tips for website performance20 tips for website performance
20 tips for website performance
 
jQuery Conference San Diego 2014 - Web Performance
jQuery Conference San Diego 2014 - Web PerformancejQuery Conference San Diego 2014 - Web Performance
jQuery Conference San Diego 2014 - Web Performance
 
Ten practical ways to improve front-end performance
Ten practical ways to improve front-end performanceTen practical ways to improve front-end performance
Ten practical ways to improve front-end performance
 
Word press optimizations
Word press optimizations Word press optimizations
Word press optimizations
 
Website & Internet + Performance testing
Website & Internet + Performance testingWebsite & Internet + Performance testing
Website & Internet + Performance testing
 
Security and why you need to review yours.
Security and why you need to review yours.Security and why you need to review yours.
Security and why you need to review yours.
 
Troubleshooting SEO for JS Frameworks - Patrick Stox - DTD 2018
Troubleshooting SEO for JS Frameworks - Patrick Stox - DTD 2018Troubleshooting SEO for JS Frameworks - Patrick Stox - DTD 2018
Troubleshooting SEO for JS Frameworks - Patrick Stox - DTD 2018
 
Navigating the critical rendering path - Jamie Alberico - VirtuaCon
Navigating the critical rendering path -  Jamie Alberico - VirtuaConNavigating the critical rendering path -  Jamie Alberico - VirtuaCon
Navigating the critical rendering path - Jamie Alberico - VirtuaCon
 
Web performance mercadolibre - ECI 2013
Web performance   mercadolibre - ECI 2013Web performance   mercadolibre - ECI 2013
Web performance mercadolibre - ECI 2013
 
performance.ppt
performance.pptperformance.ppt
performance.ppt
 
Optimizing your WordPress website
Optimizing your WordPress websiteOptimizing your WordPress website
Optimizing your WordPress website
 
7 Habits of Exceptional Performance
7 Habits of Exceptional Performance7 Habits of Exceptional Performance
7 Habits of Exceptional Performance
 
The need for Speed: Advanced #webperf - SEOday 2018
The need for Speed: Advanced #webperf - SEOday 2018The need for Speed: Advanced #webperf - SEOday 2018
The need for Speed: Advanced #webperf - SEOday 2018
 

Recently uploaded

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 

Recently uploaded (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 

Ilya Grigorik on Preconnect, Prefetch, Prerender for Faster Page Loads

  • 1. Ilya Grigorik - @igrigorik igrigorik@google.com Preconnect, prefetch, prerender ... aka, building a web performance oracle in your application!
  • 2. @igrigorikblink-dev thread Top 1M Alexa sites... ● Cable profile (5Mbps / 28 ms RTT) ● Main thread attribution in Blink ○ Measured via Telemetry ● 69.5% of time blocked on network ● 6.6% of time blocked JavaScript ● 5.1% blocked on Layout ● 4.5% blocked on Paint ● ... ● No surprise here (hopefully) ○ First page load is network bound ○ First page load is latency bound
  • 3. Our pages consist of dozens of assets Primer on Web Performance (Chapter 10) … (snip 30 requests) ... ● 52 requests ● 4+ seconds Huh? @igrigorik
  • 4. Speed, performance and human perception “Connection view” tells the story... ● 30 connections ○ DNS lookups ○ TCP handshakes ○ … ● Blue: download time @igrigorik We’re not BW limited, we’re literally idling, waiting on the network to deliver resources.
  • 5. Let’s build a smarter browser! We can hide some of the network latency through clever tricks.
  • 6. The pre-* party... Primer on Web Performance (Chapter 10) @igrigorik Preresolve Preconnect Prefetch Prerender
  • 7. @igrigorik Pre-resolve DNS names on browser startup... ● Scenario: when you load the browser first thing in the morning (or after restart), where do you usually head? ● Let’s pre-resolve all of the popular names! ○ Chrome resolves top 10 destinations. Head to chrome://dns/ to see your list. High Performance Networking in Google Chrome
  • 8. @igrigorik Preresolve is cute, but does it help much? ● How fast is your local DNS? Chrome knows the answer... chrome://histograms/DNS ● Good case: < 30 ms ● Average: 30-100 ms ● Ouch: 100 ms+ High Performance Networking in Google Chrome
  • 9. @igrigorik Let’s predict where you’re heading next... If you type in “ama” what’s the likelihood you’re heading to Amazon? ● Chrome tracks the hit / miss count, and uses it to initiate DNS preresolve and TCP preconnect! ● High confidence hits may trigger a full prerender in a background tab. ● Head to chrome://predictors/ to see your list. High Performance Networking in Google Chrome
  • 10. @igrigorik Hmm, pre-rendering you say? Tell me more... High Performance Networking in Google Chrome ● Head to chrome://net-internals/#prerender ● Try it yourself via prerender-test.appspot.com.
  • 11. @igrigorik Instant Pages *is* Chrome Prerendering! High Performance Networking in Google Chrome
  • 12. @igrigorik Could we optimize repeat visits further? Why, yes! High Performance Networking in Google Chrome ● Remember subresource hostnames + track stats on pre{connect, resolve} rates ● Use above information on future navigations to initiate appropriate actions... Check your own site: chrome://dns
  • 13. @igrigorik Can we discover critical resources quicker? Yep... Chrome preloader Chrome’s preloader delivers a ~20% speed improvement! ● Blocking resources block DOM construction... ● Preload scanner “looks ahead” in the HTML document to identify critical resources ○ JavaScript, CSS, etc. Don’t hide your resources from the preload scanner! E.g. JS loaders, polyfills, etc.
  • 14. “We were using XHR to download CSS... When it came it our attention that XHRs are requested at low priority we decided to run an experiment to see its impact on G+ latency (vs using declarative markup like <link>). In SPDY capable browsers it (using <link>) resulted in a big latency improvement. In Chrome 27 we saw a 4x speedup at the median, and 5x at 25th percentile. In Firefox 21 we saw a 5x speedup at median, and 8x at 25th percentile.” Shubhie Panicker - G+ Front-end Team
  • 15. In short, Chrome does a lot! but you can help it…
  • 16. Speed is a feature (Chapter 1) @igrigorik The browser is trying to predict and anticipate user activity, but you have the app-specific insights - leverage them! 1. Pre-resolve DNS hostnames 2. Mark critical subresources (don’t hide them!) 3. Prefetch critical resources 4. Prerender where applicable
  • 17. @igrigorik Embed “dns-prefetch” hints... Embed prefetch hints in <head> to hint the browser to pre-resolve these names. ● Useful for critical resources later in the page ● Useful for resources behind a redirect ○ host1.com/resource > 301 > host2.com/resouce ■ dns-prefetch: host2.com ○ (or even better, eliminate the redirect :)) <link rel="dns-prefetch" href="hostname_to_resolve.com"> <link rel="dns-prefetch" href="host2.com"> High Performance Networking in Google Chrome
  • 18. @igrigorik Embed “subresource” hints... Embed subresource hints in <head> to initiate immediate fetch for current page! ● Subresource hint identifies critical resources required for current page load. ● Place subresource hints as early as possible. ○ In a way, this is a “manual preload scanner” strategy ... <link rel="subresource" href="critical/app.js"> <link rel="subresource" href="critical/style.css"> High Performance Networking in Google Chrome
  • 19. @igrigorik Embed “prefetch” hints... Embed prefetch hints in <head> to initiate deferred fetch for later navigation. ● Prefetch hint identifies resources that may be needed in future navigation. ● Prefetch hints have lowest possible priority. ● Prefetch hints are content agnostic: fetch asset, place in cache. ○ You do have cache headers enabled, right? Right? <link rel="prefetch" href="checkout.html"> <link rel="prefetch" href="other-styles.css"> High Performance Networking in Google Chrome
  • 20. @igrigorik Embed “prerender” hints... Embed prerender hints in <head> to initiate background prerender of entire page! ● The page is fetch, and all of its assets! ● Use Page Visibility API to defer JS actions until page is visible. ○ Analytics beacons (GA does this already), custom code, etc. ● Only “safe” pages can be prerendered (aka, GET). ● Prerendering is resource heavy - use with caution. <link rel="prerender" href="checkout.html"> High Performance Networking in Google Chrome
  • 21. Predict, measure, optimize… iterate. You can inject each of the hints when the page is generated ○ You know the structure of the page / application, use it... ○ Run offline log analysis (e.g. step_a.html > step_b.html) You can inject hints “at runtime” based on user interactions! ○ Via the magic of JavaScript, simply add the appropriate link tag: var hint = document.createElement("link") hint.setAttribute("rel", "prerender") hint.setAttribute("href", "next-page.html") document.getElementsByTagName("head")[0].appendChild(hint) P.S. If the hint is no longer relevant, reverse works also.. nuke it from the DOM!
  • 22. Twitter igrigorik Email igrigorik@google.com Web igvita.com TL;DR 1. <link rel="dns-prefetch" href="hostname_to_resolve.com"> a. Pre-resolve DNS hostnames for assets later in the page! (Most browsers) 2. <link rel="subresource" href="/javascript/myapp.js"> a. Initiate early resource fetch for current navigation (Chrome only) 3. <link rel="prefetch" href="/images/big.jpeg"> a. Prefetch asset for a future navigation, place in cache… (Most browsers) 4. <link rel="prerender" href="//example.org/next_page.html"> a. Prerender page in background tab for future navigation ● Slides @ bit.ly/1bUFCsI ● Checkout Steve’s prebrowsing slides!