SlideShare a Scribd company logo
1 of 53
V I R T U A L C O N F E R E N C E / / N O V - D E C 2 0 2 0 / / P R E S E N T E D B Y E P A M
V I R T U A L C O N F E R E N C E / / N O V - D E C 2 0 2 0 / / P R E S E N T E D B Y E P A M
Writing Performant
Front-end Code
LY U B O M I R B O Z H I N O V
ADAPT BY ZED
Who Am I?
Lyu b omir
B ozh in ov
Lead Software Engineer
Lead Software Engineer @ EPAM. Author. Speaker.
But most importantly, a tinkerer at heart, who
believes one should always leave the code better
than they found it - and apply the same to
everything.
3
About Me
4
About Me
So, yeah, I write code for a living.
5
About Me
Sometimes I even know why it works!
ADAPT BY ZED
• MAKE IT WORK
• MAKE IT FAST
• MAKE IT PRETTY
6
Intro
ADAPT BY ZED
• MAKE IT WORK
• MAKE IT FAST
• MAKE IT PRETTY
HOW OFTEN DO YOU IGNORE CODE PERFORMANCE?
7
Intro
Level Zero: Code Performance
The Art of the Tinkerer
1
ADAPT BY ZED
9
Computational Complexity: Time v Space
Sometimes the best way to visualise something is with
a poor drawing of random ‘wibbly-wobbly’ lines.
ADAPT BY ZED
10
Computational Complexity: The Problem
In the classic find all anagrams in a dataset problem,
you could iterate every time. Or just pre-process and use KVPs.
v
ADAPT BY ZED
11
Computational Complexity: Time v Space
Hungry, hungry Chrome tabs!
ADAPT BY ZED
12
Computational Complexity: Time v Space
CompSci101 Reference
13
Premature Optimisation
What do I mean by that?
Basically any situation where one
tries to make the code run faster
before even having completed the
functionality.
14
Level Zero Fast?
Speed can be weird at this level.
15
Measure!
Measure your code speed!
And do it with enough consistency
across the codebase to have an
early-warning system for
performance problems.
16
Measure How?
USER TIMING API
MARKS & MEASURES
https://developer.mozilla.org/en-
US/docs/Web/API/User_Timing_API
ADAPT BY ZED
https://caniuse.com/#search=user-timing
17
Measure How?
ADAPT BY ZEDLevel Zero: How & Why?
18
WHY
MEASURE
LOG
TINKER
RINSE
REPEAT
SLOW CODE IS BAD
HOW
Level One: Rendering
Performance
Precision is the Key
2
ADAPT BY ZED
Our favourite language in the multiverse is single-threaded. 
20
The Event Loop
ADAPT BY ZED
The Pixel Pipeline. Source: web.dev
21
The Pixel Pipeline
Say ‘hello’ to your new best friend!
22
The Performance Tab
23
Optimise Your JS
Your code drives the entire pipeline!
ADAPT BY ZED
Changing an element’s width or class will trigger visual
changes. ‘It’s only logical.’
24
Optimise Your JS
ADAPT BY ZED
Anything small that will trigger a visual update should be done
in a RAF call to ensure it’s finished on time. No setTimeout!
25
Optimise Your JS
ADAPT BY ZED
Split the work into smaller tasks, push them onto a stack, and
then use RAF calls to deal with them one by one.
26
Optimise Your JS
ADAPT BY ZED
Just spin up a web worker to keep the main thread free of the
long-running computation.
27
Optimise Your JS
ADAPT BY ZED
The possibilities are endless.
28
Optimise Your JS
ADAPT BY ZED
Jason Miller (@developit)
29
Optimise Your JS
greenlet: https://www.npmjs.com/package/greenlet
workerize: https://www.npmjs.com/package/workerize-loader
30
Improve Style Calculations
We all joke around that CSS is a necessary evil, but the reality
is that we simply MUST try to keep it in check.
31
Improve Style Calculations
SMACSS: http://smacss.com/
BEM: http://getbem.com/introduction/
https://www.smashingmagazine.com/20
13/10/challenging-css-best-practices-
atomic-approach/
32
Minimise Layout Complexity
The fewer elements you have in your DOM tree, the
more quickly the browser will calculate the locations and
dimensions of all of them.
33
Paint and Compositing
• All property changes except transform and
opacity will trigger a repaint.
• Identify excessive paints with the dev tools
and create a separate layer.
• But too many layers at the compositing
stage can have a performance impact.
ADAPT BY ZED
The four parts of the RAIL model are basically four
perspectives on a web app’s state. Picture source: web.dev
34
The RAIL Model
ADAPT BY ZEDThe RAIL Model
35
10ms50ms
ADAPT BY ZED
Source: web.dev
36
The RAIL Model
ADAPT BY ZEDLevel One: How & Why?
37
WHY
THE PERFORMANCE TAB
OPTIMISE JAVASCRIPT EXECUTION
IMPROVE STYLE CALCULATIONS
MINIMISE LAYOUT COMPLEXITY
SIMPLIFY PAINT AND MANAGE LAYERS
KEEP THE RAIL MODEL IN MIND
VISUAL JANK AND STUTTER IS JUST BAD
UX
SLOW RENDERING WILL MAKE THE
USER FRUSTRATED
HOW
Level Two: Framework and
Bundle
Optimise Everything!
3
ADAPT BY ZED
There are number of other auto-magical features in modern
frameworks – usually just a boolean flag in a JSON file.
39
The Pros and Cons of Frameworks
ADAPT BY ZED
I’ve had the misfortune to write jQuery in IE6. It was about as
fun as it sounds.
40
The Pros and Cons of Frameworks
ADAPT BY ZED
Bundle analyzer: https://www.npmjs.com/package/webpack-
bundle-analyzer
41
The Pros and Cons of Frameworks
ADAPT BY ZED
Redux + React
42
The Pros and Cons of Frameworks
ADAPT BY ZED
Preact + Unistore
https://preactjs.com/
https://www.npmjs.com/package/unistore
43
The Pros and Cons of Frameworks
ADAPT BY ZED
Intro to PWAs: https://web.dev/progressive-web-apps
44
Going PWA
Lighthouse CI:
https://github.com/GoogleChrome/l
ighthouse-ci
45
Shed Some Light
ADAPT BY ZEDLevel Two: How & Why?
46
WHY
‘RIGHT TOOL FOR THE JOB’ TO ACHIEVE A GREAT USER EXPERIENCE
HOW
Level Three: The Network
Waterfall
Every Byte Matters
4
ADAPT BY ZED
It requires an absurd amount of tinkering to get it right. And
the solution is different for every project.
48
The Network Waterfall
ADAPT BY ZED
Addy Osmani (@addyosmani)
49
Optimise Your JS
critical: https://github.com/addyosmani/critical
ADAPT BY ZEDLevel Three: How & Why?
50
WHY
SOMEWHAT CLEAR CRYSTAL CLEAR
HOW
ADAPT BY ZED
None of the things I’ve mentioned here today are FINAL.
51
Final Words
52
Final Words
Largest Contentful Paint (LCP)
First Input Delay (FID)
Cumulative Layout Shift (CLS)
Total Blocking Time (TBT)
Keep an eye on https://web.dev
V I R T U A L C O N F E R E N C E / / N O V - D E C 2 0 2 0 / / P R E S E N T E D B Y E P A M
Thank you!
LinkedIn: https://www.linkedin.com/in/lyubomir-bozhinov/
Twitter: https://twitter.com/TheElegantDev

More Related Content

What's hot

Joel Arvidsson, Klarna. What You See is What You Get – a case for visual testing
Joel Arvidsson, Klarna. What You See is What You Get – a case for visual testingJoel Arvidsson, Klarna. What You See is What You Get – a case for visual testing
Joel Arvidsson, Klarna. What You See is What You Get – a case for visual testingIT Arena
 
Testing Storm components with Groovy and Spock
Testing Storm components with Groovy and SpockTesting Storm components with Groovy and Spock
Testing Storm components with Groovy and SpockEugene Dvorkin
 
Groovy - Why and Where?
Groovy  - Why and Where?Groovy  - Why and Where?
Groovy - Why and Where?Naresha K
 
[D2대학생세미나] frontend개발자가 들려주는 개발 이야기
[D2대학생세미나] frontend개발자가 들려주는 개발 이야기[D2대학생세미나] frontend개발자가 들려주는 개발 이야기
[D2대학생세미나] frontend개발자가 들려주는 개발 이야기NAVER D2
 
Discovery Education streaming and Google Earth
Discovery Education streaming and Google EarthDiscovery Education streaming and Google Earth
Discovery Education streaming and Google EarthMike Bryant
 
Ops is dead. long live ops.
Ops is dead. long live ops.Ops is dead. long live ops.
Ops is dead. long live ops.Outlyer
 
Large Scale Crash Dump Analysis with SuperDump
Large Scale Crash Dump Analysis with SuperDumpLarge Scale Crash Dump Analysis with SuperDump
Large Scale Crash Dump Analysis with SuperDumpChristoph Neumüller
 
息子たちがローマ字勉強するための <s>HTML5</s> Web標準 アプリ作ってみた
息子たちがローマ字勉強するための <s>HTML5</s> Web標準 アプリ作ってみた息子たちがローマ字勉強するための <s>HTML5</s> Web標準 アプリ作ってみた
息子たちがローマ字勉強するための <s>HTML5</s> Web標準 アプリ作ってみたJun-ichi Sakamoto
 
那些年,我們一起玩的萬花筒(Kaliedoscopic)
那些年,我們一起玩的萬花筒(Kaliedoscopic)那些年,我們一起玩的萬花筒(Kaliedoscopic)
那些年,我們一起玩的萬花筒(Kaliedoscopic)PRADA Hsiung
 
html5 & phonegap
html5 & phonegaphtml5 & phonegap
html5 & phonegapCaesar Chi
 
Follow these reasons to know java’s importance
Follow these reasons to know java’s importanceFollow these reasons to know java’s importance
Follow these reasons to know java’s importancenishajj
 
YeurDreamin' - Put the Wow! into your Flow with Lightning Experience
YeurDreamin'  - Put the Wow! into your Flow with Lightning ExperienceYeurDreamin'  - Put the Wow! into your Flow with Lightning Experience
YeurDreamin' - Put the Wow! into your Flow with Lightning ExperienceDaniel Stange
 

What's hot (16)

Coffee script throwdown
Coffee script throwdownCoffee script throwdown
Coffee script throwdown
 
Deployment talk dpc 13
Deployment talk dpc 13Deployment talk dpc 13
Deployment talk dpc 13
 
Joel Arvidsson, Klarna. What You See is What You Get – a case for visual testing
Joel Arvidsson, Klarna. What You See is What You Get – a case for visual testingJoel Arvidsson, Klarna. What You See is What You Get – a case for visual testing
Joel Arvidsson, Klarna. What You See is What You Get – a case for visual testing
 
Testing Storm components with Groovy and Spock
Testing Storm components with Groovy and SpockTesting Storm components with Groovy and Spock
Testing Storm components with Groovy and Spock
 
Groovy - Why and Where?
Groovy  - Why and Where?Groovy  - Why and Where?
Groovy - Why and Where?
 
[D2대학생세미나] frontend개발자가 들려주는 개발 이야기
[D2대학생세미나] frontend개발자가 들려주는 개발 이야기[D2대학생세미나] frontend개발자가 들려주는 개발 이야기
[D2대학생세미나] frontend개발자가 들려주는 개발 이야기
 
Discovery Education streaming and Google Earth
Discovery Education streaming and Google EarthDiscovery Education streaming and Google Earth
Discovery Education streaming and Google Earth
 
Ops is dead. long live ops.
Ops is dead. long live ops.Ops is dead. long live ops.
Ops is dead. long live ops.
 
Large Scale Crash Dump Analysis with SuperDump
Large Scale Crash Dump Analysis with SuperDumpLarge Scale Crash Dump Analysis with SuperDump
Large Scale Crash Dump Analysis with SuperDump
 
息子たちがローマ字勉強するための <s>HTML5</s> Web標準 アプリ作ってみた
息子たちがローマ字勉強するための <s>HTML5</s> Web標準 アプリ作ってみた息子たちがローマ字勉強するための <s>HTML5</s> Web標準 アプリ作ってみた
息子たちがローマ字勉強するための <s>HTML5</s> Web標準 アプリ作ってみた
 
那些年,我們一起玩的萬花筒(Kaliedoscopic)
那些年,我們一起玩的萬花筒(Kaliedoscopic)那些年,我們一起玩的萬花筒(Kaliedoscopic)
那些年,我們一起玩的萬花筒(Kaliedoscopic)
 
html5 & phonegap
html5 & phonegaphtml5 & phonegap
html5 & phonegap
 
Follow these reasons to know java’s importance
Follow these reasons to know java’s importanceFollow these reasons to know java’s importance
Follow these reasons to know java’s importance
 
React native
React nativeReact native
React native
 
Test stack
Test stackTest stack
Test stack
 
YeurDreamin' - Put the Wow! into your Flow with Lightning Experience
YeurDreamin'  - Put the Wow! into your Flow with Lightning ExperienceYeurDreamin'  - Put the Wow! into your Flow with Lightning Experience
YeurDreamin' - Put the Wow! into your Flow with Lightning Experience
 

Similar to Writing Performant Front-end Code

Riereta Node.js session 3 (with notes)
Riereta Node.js session 3 (with notes)Riereta Node.js session 3 (with notes)
Riereta Node.js session 3 (with notes)Tekno Paul
 
Node.JS Expreee.JS scale webapp on Google cloud
Node.JS Expreee.JS scale webapp on Google cloudNode.JS Expreee.JS scale webapp on Google cloud
Node.JS Expreee.JS scale webapp on Google cloudJimish Parekh
 
The Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingThe Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingAndrey Karpov
 
The Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingThe Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingPVS-Studio
 
C++ on the Web: Run your big 3D game in the browser
C++ on the Web: Run your big 3D game in the browserC++ on the Web: Run your big 3D game in the browser
C++ on the Web: Run your big 3D game in the browserAndre Weissflog
 
Oh the compilers you'll build
Oh the compilers you'll buildOh the compilers you'll build
Oh the compilers you'll buildMark Stoodley
 
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneWhen Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneDavid Glick
 
Intro to Node.js (for .NET Developers)
Intro to Node.js (for .NET Developers)Intro to Node.js (for .NET Developers)
Intro to Node.js (for .NET Developers)David Neal
 
Checking the Source SDK Project
Checking the Source SDK ProjectChecking the Source SDK Project
Checking the Source SDK ProjectAndrey Karpov
 
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...mCloud
 
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...Hafez Kamal
 
Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.
Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.
Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.UA Mobile
 
2019 StartIT - Boosting your performance with Blackfire
2019 StartIT - Boosting your performance with Blackfire2019 StartIT - Boosting your performance with Blackfire
2019 StartIT - Boosting your performance with BlackfireMarko Mitranić
 
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...andreaslubbe
 
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...DevSecCon
 
WordPress automation and CI
WordPress automation and CIWordPress automation and CI
WordPress automation and CIRan Bar-Zik
 

Similar to Writing Performant Front-end Code (20)

Riereta Node.js session 3 (with notes)
Riereta Node.js session 3 (with notes)Riereta Node.js session 3 (with notes)
Riereta Node.js session 3 (with notes)
 
Node.JS Expreee.JS scale webapp on Google cloud
Node.JS Expreee.JS scale webapp on Google cloudNode.JS Expreee.JS scale webapp on Google cloud
Node.JS Expreee.JS scale webapp on Google cloud
 
Node.js
Node.jsNode.js
Node.js
 
The Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingThe Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and Everything
 
The Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and EverythingThe Ultimate Question of Programming, Refactoring, and Everything
The Ultimate Question of Programming, Refactoring, and Everything
 
C++ on the Web: Run your big 3D game in the browser
C++ on the Web: Run your big 3D game in the browserC++ on the Web: Run your big 3D game in the browser
C++ on the Web: Run your big 3D game in the browser
 
Oh the compilers you'll build
Oh the compilers you'll buildOh the compilers you'll build
Oh the compilers you'll build
 
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneWhen Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
 
Intro to Node.js (for .NET Developers)
Intro to Node.js (for .NET Developers)Intro to Node.js (for .NET Developers)
Intro to Node.js (for .NET Developers)
 
Checking the Source SDK Project
Checking the Source SDK ProjectChecking the Source SDK Project
Checking the Source SDK Project
 
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
 
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
 
Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.
Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.
Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.
 
Web Leaps Forward
Web Leaps ForwardWeb Leaps Forward
Web Leaps Forward
 
2019 StartIT - Boosting your performance with Blackfire
2019 StartIT - Boosting your performance with Blackfire2019 StartIT - Boosting your performance with Blackfire
2019 StartIT - Boosting your performance with Blackfire
 
Cucumber - Maria Machlowska
Cucumber - Maria MachlowskaCucumber - Maria Machlowska
Cucumber - Maria Machlowska
 
10 Ways To Improve Your Code
10 Ways To Improve Your Code10 Ways To Improve Your Code
10 Ways To Improve Your Code
 
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
Beautiful code instead of callback hell using ES6 Generators, Koa, Bluebird (...
 
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
 
WordPress automation and CI
WordPress automation and CIWordPress automation and CI
WordPress automation and CI
 

Recently uploaded

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Recently uploaded (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Writing Performant Front-end Code

  • 1. V I R T U A L C O N F E R E N C E / / N O V - D E C 2 0 2 0 / / P R E S E N T E D B Y E P A M
  • 2. V I R T U A L C O N F E R E N C E / / N O V - D E C 2 0 2 0 / / P R E S E N T E D B Y E P A M Writing Performant Front-end Code LY U B O M I R B O Z H I N O V
  • 3. ADAPT BY ZED Who Am I? Lyu b omir B ozh in ov Lead Software Engineer Lead Software Engineer @ EPAM. Author. Speaker. But most importantly, a tinkerer at heart, who believes one should always leave the code better than they found it - and apply the same to everything. 3 About Me
  • 4. 4 About Me So, yeah, I write code for a living.
  • 5. 5 About Me Sometimes I even know why it works!
  • 6. ADAPT BY ZED • MAKE IT WORK • MAKE IT FAST • MAKE IT PRETTY 6 Intro
  • 7. ADAPT BY ZED • MAKE IT WORK • MAKE IT FAST • MAKE IT PRETTY HOW OFTEN DO YOU IGNORE CODE PERFORMANCE? 7 Intro
  • 8. Level Zero: Code Performance The Art of the Tinkerer 1
  • 9. ADAPT BY ZED 9 Computational Complexity: Time v Space Sometimes the best way to visualise something is with a poor drawing of random ‘wibbly-wobbly’ lines.
  • 10. ADAPT BY ZED 10 Computational Complexity: The Problem In the classic find all anagrams in a dataset problem, you could iterate every time. Or just pre-process and use KVPs. v
  • 11. ADAPT BY ZED 11 Computational Complexity: Time v Space Hungry, hungry Chrome tabs!
  • 12. ADAPT BY ZED 12 Computational Complexity: Time v Space CompSci101 Reference
  • 13. 13 Premature Optimisation What do I mean by that? Basically any situation where one tries to make the code run faster before even having completed the functionality.
  • 14. 14 Level Zero Fast? Speed can be weird at this level.
  • 15. 15 Measure! Measure your code speed! And do it with enough consistency across the codebase to have an early-warning system for performance problems.
  • 16. 16 Measure How? USER TIMING API MARKS & MEASURES https://developer.mozilla.org/en- US/docs/Web/API/User_Timing_API
  • 18. ADAPT BY ZEDLevel Zero: How & Why? 18 WHY MEASURE LOG TINKER RINSE REPEAT SLOW CODE IS BAD HOW
  • 20. ADAPT BY ZED Our favourite language in the multiverse is single-threaded.  20 The Event Loop
  • 21. ADAPT BY ZED The Pixel Pipeline. Source: web.dev 21 The Pixel Pipeline
  • 22. Say ‘hello’ to your new best friend! 22 The Performance Tab
  • 23. 23 Optimise Your JS Your code drives the entire pipeline!
  • 24. ADAPT BY ZED Changing an element’s width or class will trigger visual changes. ‘It’s only logical.’ 24 Optimise Your JS
  • 25. ADAPT BY ZED Anything small that will trigger a visual update should be done in a RAF call to ensure it’s finished on time. No setTimeout! 25 Optimise Your JS
  • 26. ADAPT BY ZED Split the work into smaller tasks, push them onto a stack, and then use RAF calls to deal with them one by one. 26 Optimise Your JS
  • 27. ADAPT BY ZED Just spin up a web worker to keep the main thread free of the long-running computation. 27 Optimise Your JS
  • 28. ADAPT BY ZED The possibilities are endless. 28 Optimise Your JS
  • 29. ADAPT BY ZED Jason Miller (@developit) 29 Optimise Your JS greenlet: https://www.npmjs.com/package/greenlet workerize: https://www.npmjs.com/package/workerize-loader
  • 30. 30 Improve Style Calculations We all joke around that CSS is a necessary evil, but the reality is that we simply MUST try to keep it in check.
  • 31. 31 Improve Style Calculations SMACSS: http://smacss.com/ BEM: http://getbem.com/introduction/ https://www.smashingmagazine.com/20 13/10/challenging-css-best-practices- atomic-approach/
  • 32. 32 Minimise Layout Complexity The fewer elements you have in your DOM tree, the more quickly the browser will calculate the locations and dimensions of all of them.
  • 33. 33 Paint and Compositing • All property changes except transform and opacity will trigger a repaint. • Identify excessive paints with the dev tools and create a separate layer. • But too many layers at the compositing stage can have a performance impact.
  • 34. ADAPT BY ZED The four parts of the RAIL model are basically four perspectives on a web app’s state. Picture source: web.dev 34 The RAIL Model
  • 35. ADAPT BY ZEDThe RAIL Model 35 10ms50ms
  • 36. ADAPT BY ZED Source: web.dev 36 The RAIL Model
  • 37. ADAPT BY ZEDLevel One: How & Why? 37 WHY THE PERFORMANCE TAB OPTIMISE JAVASCRIPT EXECUTION IMPROVE STYLE CALCULATIONS MINIMISE LAYOUT COMPLEXITY SIMPLIFY PAINT AND MANAGE LAYERS KEEP THE RAIL MODEL IN MIND VISUAL JANK AND STUTTER IS JUST BAD UX SLOW RENDERING WILL MAKE THE USER FRUSTRATED HOW
  • 38. Level Two: Framework and Bundle Optimise Everything! 3
  • 39. ADAPT BY ZED There are number of other auto-magical features in modern frameworks – usually just a boolean flag in a JSON file. 39 The Pros and Cons of Frameworks
  • 40. ADAPT BY ZED I’ve had the misfortune to write jQuery in IE6. It was about as fun as it sounds. 40 The Pros and Cons of Frameworks
  • 41. ADAPT BY ZED Bundle analyzer: https://www.npmjs.com/package/webpack- bundle-analyzer 41 The Pros and Cons of Frameworks
  • 42. ADAPT BY ZED Redux + React 42 The Pros and Cons of Frameworks
  • 43. ADAPT BY ZED Preact + Unistore https://preactjs.com/ https://www.npmjs.com/package/unistore 43 The Pros and Cons of Frameworks
  • 44. ADAPT BY ZED Intro to PWAs: https://web.dev/progressive-web-apps 44 Going PWA
  • 46. ADAPT BY ZEDLevel Two: How & Why? 46 WHY ‘RIGHT TOOL FOR THE JOB’ TO ACHIEVE A GREAT USER EXPERIENCE HOW
  • 47. Level Three: The Network Waterfall Every Byte Matters 4
  • 48. ADAPT BY ZED It requires an absurd amount of tinkering to get it right. And the solution is different for every project. 48 The Network Waterfall
  • 49. ADAPT BY ZED Addy Osmani (@addyosmani) 49 Optimise Your JS critical: https://github.com/addyosmani/critical
  • 50. ADAPT BY ZEDLevel Three: How & Why? 50 WHY SOMEWHAT CLEAR CRYSTAL CLEAR HOW
  • 51. ADAPT BY ZED None of the things I’ve mentioned here today are FINAL. 51 Final Words
  • 52. 52 Final Words Largest Contentful Paint (LCP) First Input Delay (FID) Cumulative Layout Shift (CLS) Total Blocking Time (TBT) Keep an eye on https://web.dev
  • 53. V I R T U A L C O N F E R E N C E / / N O V - D E C 2 0 2 0 / / P R E S E N T E D B Y E P A M Thank you! LinkedIn: https://www.linkedin.com/in/lyubomir-bozhinov/ Twitter: https://twitter.com/TheElegantDev