Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Designing High Performance React Applications
Search
Sendil Kumar N
June 01, 2022
Programming
1
140
Designing High Performance React Applications
Sendil Kumar N
June 01, 2022
Tweet
Share
More Decks by Sendil Kumar N
See All by Sendil Kumar N
[Heapcon-2023] Building High Performance Web Applications
sendilkumarn
0
71
Building Reactive Microservices with Kotlin & running on Kubernetes
sendilkumarn
0
150
Building Reactive Microservices with JHipster & K8s
sendilkumarn
0
18
Batching, Suspense, and Server Components
sendilkumarn
0
33
DevNexus_Building_with__Zero_Trust_Architecture_Copy.pdf
sendilkumarn
0
55
Lessons Learnt with Visual Testing and Snapshots
sendilkumarn
0
100
Easy Microservices with K8s & Istio
sendilkumarn
0
85
KHipster - Kotlin Hipster
sendilkumarn
0
210
Microservices with JHipster
sendilkumarn
0
72
Other Decks in Programming
See All in Programming
Tuning GraphQL on Rails
pyama86
2
1k
VR HMDとしてのVision Pro+ゲーム開発について
yasei_no_otoko
0
100
Importmapを使ったJavaScriptの 読み込みとブラウザアドオンの影響
swamp09
4
1.3k
Amazon Neptuneで始めてみるグラフDB-OpenSearchによるグラフの全文検索-
satoshi256kbyte
4
330
offers_20241022_imakiire.pdf
imakurusu
2
360
生成 AI を活用した toitta 切片分類機能の裏側 / Inside toitta's AI-Based Factoid Clustering
pokutuna
0
580
プロジェクト新規参入者のリードタイム短縮の観点から見る、品質の高いコードとアーキテクチャを保つメリット
d_endo
1
1k
Kubernetes for Data Engineers: Building Scalable, Reliable Data Pipelines
sucitw
1
200
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
1
300
Server Driven Compose With Firebase
skydoves
0
400
リリース8年目のサービスの1800個のERBファイルをViewComponentに移行した方法とその結果
katty0324
5
3.6k
Why Spring Matters to Jakarta EE - and Vice Versa
ivargrimstad
0
1k
Featured
See All Featured
Building an army of robots
kneath
302
42k
The Art of Programming - Codeland 2020
erikaheidi
51
13k
Facilitating Awesome Meetings
lara
49
6k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
355
29k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Navigating Team Friction
lara
183
14k
Docker and Python
trallard
40
3.1k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
Visualization
eitanlees
144
15k
GitHub's CSS Performance
jonrohan
1030
460k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
92
16k
Transcript
@sendilkumarn Designing High Performance React Applications
@sendilkumarn @sendilkumarn
@sendilkumarn @sendilkumarn @sendilkumarn
@sendilkumarn @sendilkumarn https://www.packt.com/product/web-development/b14844-practical-webassembly/ 30PRWEB
@sendilkumarn @sendilkumarn why performance matters?
@sendilkumarn @sendilkumarn 4.42% users drop for every additional second of
load time source
@sendilkumarn @sendilkumarn
@sendilkumarn @sendilkumarn Every 1s improvement increases CR by 2%
@sendilkumarn @sendilkumarn Every 1s improvement increases CR by 2% 10M
= 200K ⏫
@sendilkumarn @sendilkumarn 3-4s Ideal load time source
@sendilkumarn @sendilkumarn ~15s average mobile site load time source
@sendilkumarn @sendilkumarn ⚡ sites = 😄 users
@sendilkumarn @sendilkumarn 😄 users = 📈 CR
@sendilkumarn @sendilkumarn https://web.dev/vitals-business-impact/
@sendilkumarn @sendilkumarn Core Web Vitals
@sendilkumarn @sendilkumarn GET /home TTFB FCP GET /main.js Render (App)
LCP TTI Time To First Byte First Contentful Paint Largest Contentful Paint Time To Interactivity
@sendilkumarn @sendilkumarn Lower is better Source
@sendilkumarn @sendilkumarn Layout Shifts Source
@sendilkumarn @sendilkumarn Lesser Layout Shifts Sooner Time To Interactivity Faster
Largest Contentful Paint
@sendilkumarn @sendilkumarn Agenda Obvious - Things that you know already!
Rendering - Render based on your needs It depends - It actually depends on your usecase Common - Use it everywhere
@sendilkumarn @sendilkumarn Obvious
@sendilkumarn @sendilkumarn Bundling & Splitting
@sendilkumarn @sendilkumarn GET /home GET /main.js Render (App) Browser has
to wait until the main.js is downloaded fully. Smaller the size better the performance
@sendilkumarn @sendilkumarn Route based splitting Component based splitting
@sendilkumarn @sendilkumarn 100 - 170 KB is the ideal size
for the JavaScript size Budget JavaScript
@sendilkumarn @sendilkumarn Analyse JavaScript bundle size & Optimise
@sendilkumarn @sendilkumarn Avoid Data mutation
@sendilkumarn @sendilkumarn Every mutation causes re-rendering
@sendilkumarn @sendilkumarn Every re-rendering causes performance impact
@sendilkumarn @sendilkumarn Immutability
@sendilkumarn @sendilkumarn Reconciliation
@sendilkumarn @sendilkumarn
@sendilkumarn @sendilkumarn SCU SCU SCU SCU SCU SCU SCU
@sendilkumarn @sendilkumarn VDOMeq VDOMeq VDOMeq
@sendilkumarn @sendilkumarn
@sendilkumarn @sendilkumarn Architect your code / application such that re-rendering
affects lesser components in your react tree.
@sendilkumarn @sendilkumarn Virtualization
@sendilkumarn @sendilkumarn viewport
@sendilkumarn @sendilkumarn Rendered Rendered Rendered Rendered Rendered Not Rendered Not
Rendered
@sendilkumarn @sendilkumarn Source 100x
@sendilkumarn @sendilkumarn React 18 - Automatic Batching
@sendilkumarn @sendilkumarn Batching is when React groups multiple state updates
into a single re-render for a better performance
@sendilkumarn @sendilkumarn Re-rendering happens here 17
@sendilkumarn @sendilkumarn Re-rendering happens here Re-rendering happens here 17
@sendilkumarn @sendilkumarn Re-rendering happens here 18
@sendilkumarn @sendilkumarn •Better performance •No unnecessary re-renders •Consistent User Experience
•No weird intermediate state
@sendilkumarn @sendilkumarn Obvious 🔻 bundle size 🔻 re-rendering 🔻 updates
✅ virtualize ✅ React 18
@sendilkumarn @sendilkumarn Deliver only what is used
@sendilkumarn @sendilkumarn Rendering
@sendilkumarn @sendilkumarn Client Side Rendering (CSR) Static Rendering
@sendilkumarn @sendilkumarn JS CSS HTML
@sendilkumarn @sendilkumarn
@sendilkumarn @sendilkumarn 👍 Fast Time To First Byte 👍 Good
for static content 👎 Performance depends on the client 👎 TTI is high 👎 Bundle size decreases your site performance
@sendilkumarn @sendilkumarn Server Side Rendering (SSR)
@sendilkumarn @sendilkumarn SSR generates HTML from react components in server
@sendilkumarn @sendilkumarn
@sendilkumarn @sendilkumarn Loading Starts…
@sendilkumarn @sendilkumarn Server Fetches Data Renders HTML
@sendilkumarn @sendilkumarn Client receives HTML Only HTML No Interactions
@sendilkumarn @sendilkumarn Hydrate
@sendilkumarn @sendilkumarn Finish Fetching Finish Loading Finish Hydrate Interact
@sendilkumarn @sendilkumarn 👍 Fast TTI 👍 Good for dynamic content
👍 Performance doesn’t depend on the client 👎 TTFB is high 👎 High server cost
@sendilkumarn @sendilkumarn SSR CSR Dynamic Static Balance as you need
@sendilkumarn @sendilkumarn React 18 - Suspense in SSR
@sendilkumarn @sendilkumarn <suspense /> lets you wait for code to
load
@sendilkumarn @sendilkumarn <Layout> <Header /> <Sidebar /> <Main> <Post />
<Comments /> </Main> <Footer /> </Layout>
@sendilkumarn @sendilkumarn <Layout> <Header /> <Sidebar /> <Main> <Post />
<Comments /> </Main> <Footer /> </Layout>
@sendilkumarn @sendilkumarn <Layout> <Header /> <Sidebar /> <Main> <Post />
<Comments /> </Main> <Footer /> </Layout> Server Side Render
@sendilkumarn @sendilkumarn <Layout> <Header /> <Sidebar /> <Main> <Post />
<Comments /> </Main> <Footer /> </Layout> fetchPosts().then(post => { fetchCommentForPost(…) });
@sendilkumarn @sendilkumarn <Layout> <Header /> <Sidebar /> <Main> <Post />
<Suspense> <Comments /> </Suspense> </Main> <Footer /> </Layout> fetchPosts(); fetchCommentsForPost();
@sendilkumarn @sendilkumarn Finish Fetching Finish Loading Finish Hydrate Interact
@sendilkumarn @sendilkumarn Rendering
@sendilkumarn @sendilkumarn Islands Architecture Photo source Rendering
@sendilkumarn @sendilkumarn
@sendilkumarn @sendilkumarn It depends
@sendilkumarn @sendilkumarn React 18 - Server Components
@sendilkumarn @sendilkumarn Server Components are React components but they will
run on server
@sendilkumarn @sendilkumarn ⚠ Not yet production ready ⚠
@sendilkumarn @sendilkumarn *.server.js *.client.js *.js
@sendilkumarn @sendilkumarn Server Closer & Faster
@sendilkumarn @sendilkumarn blog.js 229 kb 954 kb 32 kb 1215
kb Calling DB from the client Calculates them on the client
@sendilkumarn @sendilkumarn blog.server.js Handled in server SSR HTML
@sendilkumarn @sendilkumarn 👍 No huge dependencies 👍 Props are allowed
👍 Can import *.client.js 👎 No interactivity 👎 No State / user events
@sendilkumarn @sendilkumarn Use Technologies as needed
@sendilkumarn @sendilkumarn GraphQL Redux Css in JS Lodash moment.js ……………
@sendilkumarn @sendilkumarn Limit component size
@sendilkumarn @sendilkumarn
@sendilkumarn @sendilkumarn
@sendilkumarn @sendilkumarn
@sendilkumarn @sendilkumarn VDOM eq - takes longer time Too many
updates Too complex to maintain
@sendilkumarn @sendilkumarn
@sendilkumarn @sendilkumarn Common
@sendilkumarn @sendilkumarn Cache is your friend
@sendilkumarn @sendilkumarn Edge Cache
@sendilkumarn @sendilkumarn
@sendilkumarn @sendilkumarn Image Lazy Loading
@sendilkumarn @sendilkumarn <img src=“image.png” loading=“lazy” alt=“…” /> <img src=“image.png” alt=“…”
/> <img src=“image.png” loading=“eager” alt=“…” /> <img src=“image.png” loading=“auto” alt=“…” />
@sendilkumarn @sendilkumarn Apple Macbook Site 17.5Mb only images
@sendilkumarn @sendilkumarn Source
@sendilkumarn @sendilkumarn Inline critical ; defer non-critical
@sendilkumarn @sendilkumarn Remove unused resources
@sendilkumarn @sendilkumarn
@sendilkumarn @sendilkumarn Preload Lazy load
@sendilkumarn @sendilkumarn ChromeVille DNS Land Web World DataVille Folderz hAPPy
Load HTML HTML JS CSS Parse CSS & JS Waits to fi nish download Parse & Execute Critical @sendilkumarn
@sendilkumarn @sendilkumarn Minimize roundtrips
@sendilkumarn @sendilkumarn ChromeVille DNS Land Web World DataVille Folderz hAPPy
HTML JS CSS Load HTML Parse CSS & JS Waits to fi nish download Parse & Execute APIs @sendilkumarn
@sendilkumarn @sendilkumarn Minimize roundtrips (APIs)
@sendilkumarn @sendilkumarn ChromeVille DNS Land Web World DataVille Folderz hAPPy
HTML JS CSS Load HTML Parse CSS & JS Waits to fi nish download Parse & Execute APIs SSR @sendilkumarn
@sendilkumarn @sendilkumarn React Profilers
@sendilkumarn @sendilkumarn Performance Optimisation is an ongoing process
@sendilkumarn @sendilkumarn Measure! Optimize!! Measure!!!
@sendilkumarn @sendilkumarn Questions
@sendilkumarn @sendilkumarn Thanks