SlideShare a Scribd company logo
Performance Optimization of
Vue.js Apps with modern JS
Filip Rakowski
@filrakowski
Filip Rakowski
Co-founder
Frontend Developer
Community partner
@filrakowski
Let’s talk about Performance!
*but not rendering performance, it’s a huge topic and they gave me only 25 minutes ;(
@filrakowski
Why performance is important?
@filrakowski
@filrakowski
2.2 sec load time reduction resulted in 15.4%
more downloads
Firefox
@filrakowski
1s slowdown resulted in 11% less page views
Aberdeen Group
@filrakowski
2 sec delay resulted in 4.3% loss in revenue
per visitor and 3.75% reduction in clicks
Bing
@filrakowski
cutting page load time half resulted in 13%
increase in sales
AutoAnything
@filrakowski
SPEED = MONEY
@filrakowski
What influences loading time performance?
@filrakowski
Request /
Response
@filrakowski
Request /
Response
Parsing
@filrakowski
Request /
Response
Parsing Execution
@filrakowski
Request /
Response
Parsing Execution
@filrakowski
Let’s make an app!
@filrakowski
main.jsApp.vue Vue
@filrakowski
main.jsrouter.js Vue
@filrakowski
Home.vue
About.vueLodash
vue-router app.js
App.vue
every new module or library
=
bigger bundle
@filrakowski
bigger bundle
=
longer download
@filrakowski
bigger bundle
=
longer parsing
@filrakowski
bigger bundle
=
longer execution
@filrakowski
SPEED = MONEY
@filrakowski
MORE FEATURES = LESS MONEY?
@filrakowski
@filrakowski
How webpack bundling works?
@filrakowski
Dependency graph is a graph of modules in
your application. Starting from entry point
webpack is recursively adding all imported
modules to the graph and bundles them into
(usually) one file.
@filrakowski
main.jsrouter.js Vue
@filrakowski
Home.vue
About.vueLodash
vue-router
App.vue
main.jsrouter.js Vue
@filrakowski
Home.vue
About.vueLodash
vue-router
App.vue
main.jsrouter.js Vue
@filrakowski
Home.vue
About.vueLodash
vue-router
App.vue
main.jsrouter.js Vue
@filrakowski
Home.vue
About.vueLodash
vue-router
App.vue
main.jsrouter.js Vue
@filrakowski
Home.vue
About.vueLodash
vue-router
App.vue
main.jsrouter.js Vue
@filrakowski
Home.vue
About.vueLodash
vue-router
App.vue
app.js
main.jsrouter.js Vue
@filrakowski
Home.vue
About.vueLodash
vue-router app.js
App.vue We might not
need this!
Code splitting allows you to split your code
into various bundles. You can think about this
as deferring a piece of your dependency
graph to be loaded later.
@filrakowski
Lazy loading loading chunk of code on demand
usually as a response to user action.
@filrakowski
Dynamic import
@filrakowski
@filrakowski
main.jsrouter.js Vue
@filrakowski
Home.vue
About.vueLodash
vue-router app.js
App.vue
home.js
about.js
Nuxt is doing per-route code-splitting out of the box!
@filrakowski
Rule #1 - Split your code per route
@filrakowski
What else we don’t need on initial download?
@filrakowski
@filrakowski
@filrakowski
Rule #2 - Load off-screen components lazily
@filrakowski
@filrakowski
You can use v-if to lazily
load off-screen components
What else?
@filrakowski
Rule #3 - Load non-critical libraries lazily
@filrakowski
@filrakowski
Rule #4 - Avoid bundling all 3rd party libs into
one file. It’s an anti-pattern.
@filrakowski
main.jsrouter.js Vue
@filrakowski
Home.vue
About.vueLodash
vue-router vendor.js
App.vue
main.jsrouter.js Vue
@filrakowski
Home.vue
About.vueLodash
vue-router vendor.js
App.vue
We might not
need this!
What about code duplication?
@filrakowski
main.jsrouter.js Vue
@filrakowski
Home.vue
About.vueLodash
vue-router app.js
App.vue
home.js
about.js
Lodash
main.jsrouter.js Vue
@filrakowski
Home.vue
About.vueLodash
vue-router app.js
App.vue
home.js
about.js
Lodash
@filrakowski
Rule #5 - Choose your libraries carefully and
try to find smaller equivalents if possible
@filrakowski
@filrakowski
@filrakowski
@filrakowski
Request /
Response
Parsing Execution
@filrakowski
Rule #5 - Make use of cache for static assets
@filrakowski
Service workers essentially act as proxy
servers that sit between web applications, the
browser, and the network (when available).
They can be used to serve network responses
from cache instead of a network.
@filrakowski
Service
Worker
Network
@filrakowski
Client app
Service
Worker
Network
@filrakowski
Client app
Cache
If asset was previously
downloaded
If asset is not in cache
or needs to be „fresh”
Vue CLI PWA plugin
@filrakowski
@filrakowski
Nuxt PWA module
@filrakowski
@filrakowski
@filrakowski
What else we can do?
@filrakowski
Prefetching downloading assets before they’re
requested.
@filrakowski
Rule #6 - Prefetch lazily loaded resources
@filrakowski
@filrakowski
More general options
webpack precachePlugin
workbox-webpack-plugin
@filrakowski
Vue-cli 3 is prefetching lazy chunks out of the box!
@filrakowski
Don’t forget about compression, minification and other
stuff that webpack and DevOps will do for you
@filrakowski
Measuring and analyzing
@filrakowski
#1 Dev tools “coverage” tool
@filrakowski
@filrakowski
CMD + Shift + P “Coverage”
@filrakowski
Everything marked with red should probably be loaded lazily
#2 Webpack bundle analyzer
@filrakowski
@filrakowski
@filrakowski
#2 ‘bundlesize’ package
@filrakowski
@filrakowski
@filrakowski
#3 VS Code ‘Import cost’ plugin
@filrakowski
@filrakowski
Thank you!
If you already forgot something - don’t worry.
I’ll share the slides :)
@filrakowski

More Related Content

What's hot

10 top web development frameworks (new version 21 11)
10 top web development frameworks (new version 21 11)10 top web development frameworks (new version 21 11)
10 top web development frameworks (new version 21 11)
Mandar Majmudar
 
Aeternity Blockchain - Ecosystem & Devtools [2019]
Aeternity Blockchain - Ecosystem & Devtools [2019]Aeternity Blockchain - Ecosystem & Devtools [2019]
Aeternity Blockchain - Ecosystem & Devtools [2019]
Przemysław Thomann
 
Architecture & Workflow of Modern Web Apps
Architecture & Workflow of Modern Web AppsArchitecture & Workflow of Modern Web Apps
Architecture & Workflow of Modern Web Apps
Rasheed Waraich
 
What’s new in LightSwitch 2013?
What’s new in LightSwitch 2013?What’s new in LightSwitch 2013?
What’s new in LightSwitch 2013?Robert MacLean
 
Micro frontends
Micro frontendsMicro frontends
Micro frontends
Kleyson Prado
 
Windows 8
Windows 8Windows 8
Windows 8
Robert MacLean
 
Visual Studio: The best tool for web developers.
Visual Studio: The best tool for web developers.Visual Studio: The best tool for web developers.
Visual Studio: The best tool for web developers.
Robert MacLean
 
Micro-Frontends JSVidCon
Micro-Frontends JSVidConMicro-Frontends JSVidCon
Micro-Frontends JSVidCon
Amir Zuker
 
Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...
Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...
Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...
Shift Conference
 
Fronted development trends - past, present and the future
Fronted development trends - past, present and the futureFronted development trends - past, present and the future
Fronted development trends - past, present and the future
Harijs Deksnis
 
Web Development and Web Development technologies - Temitayo Fadojutimi
Web Development and Web Development technologies - Temitayo FadojutimiWeb Development and Web Development technologies - Temitayo Fadojutimi
Web Development and Web Development technologies - Temitayo Fadojutimi
Temitayo Fadojutimi
 
Magento 2 Module in 50 Minutes
Magento 2 Module in 50 MinutesMagento 2 Module in 50 Minutes
Magento 2 Module in 50 Minutes
Ben Marks
 
How To be a Backend developer
How To be a Backend developer    How To be a Backend developer
How To be a Backend developer
Ramy Hakam
 
Full stack web development
Full stack web developmentFull stack web development
Full stack web development
Crampete
 
Joomla as a mobile App backend - ideas, examples and experiences
Joomla as a mobile App backend - ideas, examples and experiencesJoomla as a mobile App backend - ideas, examples and experiences
Joomla as a mobile App backend - ideas, examples and experiences
Andy_Gaskell
 
PWA for PHP Developers
PWA for PHP DevelopersPWA for PHP Developers
PWA for PHP Developers
Ben Marks
 
What Web Framework To Use?
What Web Framework To Use?What Web Framework To Use?
What Web Framework To Use?
Kasra Khosravi
 
Progressive Web Apps / GDG DevFest - Season 2016
Progressive Web Apps / GDG DevFest - Season 2016Progressive Web Apps / GDG DevFest - Season 2016
Progressive Web Apps / GDG DevFest - Season 2016
Abdelrahman Omran
 
Continuous workflow for a large react native app - mobile at wix
Continuous workflow for a large react native app - mobile at wixContinuous workflow for a large react native app - mobile at wix
Continuous workflow for a large react native app - mobile at wix
Shalom Yerushalmy
 

What's hot (19)

10 top web development frameworks (new version 21 11)
10 top web development frameworks (new version 21 11)10 top web development frameworks (new version 21 11)
10 top web development frameworks (new version 21 11)
 
Aeternity Blockchain - Ecosystem & Devtools [2019]
Aeternity Blockchain - Ecosystem & Devtools [2019]Aeternity Blockchain - Ecosystem & Devtools [2019]
Aeternity Blockchain - Ecosystem & Devtools [2019]
 
Architecture & Workflow of Modern Web Apps
Architecture & Workflow of Modern Web AppsArchitecture & Workflow of Modern Web Apps
Architecture & Workflow of Modern Web Apps
 
What’s new in LightSwitch 2013?
What’s new in LightSwitch 2013?What’s new in LightSwitch 2013?
What’s new in LightSwitch 2013?
 
Micro frontends
Micro frontendsMicro frontends
Micro frontends
 
Windows 8
Windows 8Windows 8
Windows 8
 
Visual Studio: The best tool for web developers.
Visual Studio: The best tool for web developers.Visual Studio: The best tool for web developers.
Visual Studio: The best tool for web developers.
 
Micro-Frontends JSVidCon
Micro-Frontends JSVidConMicro-Frontends JSVidCon
Micro-Frontends JSVidCon
 
Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...
Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...
Shift Remote FRONTEND: Micro Frontend Architecture: A Look Into the Future - ...
 
Fronted development trends - past, present and the future
Fronted development trends - past, present and the futureFronted development trends - past, present and the future
Fronted development trends - past, present and the future
 
Web Development and Web Development technologies - Temitayo Fadojutimi
Web Development and Web Development technologies - Temitayo FadojutimiWeb Development and Web Development technologies - Temitayo Fadojutimi
Web Development and Web Development technologies - Temitayo Fadojutimi
 
Magento 2 Module in 50 Minutes
Magento 2 Module in 50 MinutesMagento 2 Module in 50 Minutes
Magento 2 Module in 50 Minutes
 
How To be a Backend developer
How To be a Backend developer    How To be a Backend developer
How To be a Backend developer
 
Full stack web development
Full stack web developmentFull stack web development
Full stack web development
 
Joomla as a mobile App backend - ideas, examples and experiences
Joomla as a mobile App backend - ideas, examples and experiencesJoomla as a mobile App backend - ideas, examples and experiences
Joomla as a mobile App backend - ideas, examples and experiences
 
PWA for PHP Developers
PWA for PHP DevelopersPWA for PHP Developers
PWA for PHP Developers
 
What Web Framework To Use?
What Web Framework To Use?What Web Framework To Use?
What Web Framework To Use?
 
Progressive Web Apps / GDG DevFest - Season 2016
Progressive Web Apps / GDG DevFest - Season 2016Progressive Web Apps / GDG DevFest - Season 2016
Progressive Web Apps / GDG DevFest - Season 2016
 
Continuous workflow for a large react native app - mobile at wix
Continuous workflow for a large react native app - mobile at wixContinuous workflow for a large react native app - mobile at wix
Continuous workflow for a large react native app - mobile at wix
 

Similar to Performance optimization of vue.js apps with modern js

Filip Rakowski "Web Performance in modern JavaScript world"
Filip Rakowski "Web Performance in modern JavaScript world"Filip Rakowski "Web Performance in modern JavaScript world"
Filip Rakowski "Web Performance in modern JavaScript world"
Fwdays
 
Web Frameworks of the Future
Web Frameworks of the FutureWeb Frameworks of the Future
Web Frameworks of the Futureelliando dias
 
Long life to vagrant… Vagrant is dead
Long life to vagrant… Vagrant is deadLong life to vagrant… Vagrant is dead
Long life to vagrant… Vagrant is dead
Federico Panini
 
"You’re probably using Lighthouse wrong: How do we misuse the most common too...
"You’re probably using Lighthouse wrong: How do we misuse the most common too..."You’re probably using Lighthouse wrong: How do we misuse the most common too...
"You’re probably using Lighthouse wrong: How do we misuse the most common too...
Fwdays
 
FFWD.PRO - It's not you, It's me (or how to avoid being coupled with a Javasc...
FFWD.PRO - It's not you, It's me (or how to avoid being coupled with a Javasc...FFWD.PRO - It's not you, It's me (or how to avoid being coupled with a Javasc...
FFWD.PRO - It's not you, It's me (or how to avoid being coupled with a Javasc...
Marco Cedaro
 
Refactoring to Go modules: why and how
Refactoring to Go modules: why and howRefactoring to Go modules: why and how
Refactoring to Go modules: why and how
Leon Stigter
 
Phonegap 1.0
Phonegap 1.0Phonegap 1.0
Phonegap 1.0
Brian LeRoux
 
Web Components: The Future of Web Development is Here
Web Components: The Future of Web Development is HereWeb Components: The Future of Web Development is Here
Web Components: The Future of Web Development is Here
John Riviello
 
Practical WebAssembly with Apex, wasmRS, and nanobus
Practical WebAssembly with Apex, wasmRS, and nanobusPractical WebAssembly with Apex, wasmRS, and nanobus
Practical WebAssembly with Apex, wasmRS, and nanobus
Jarrod Overson
 
Selje_Amazing VFP2C32 Library.pdf
Selje_Amazing VFP2C32 Library.pdfSelje_Amazing VFP2C32 Library.pdf
Selje_Amazing VFP2C32 Library.pdf
Eric Selje
 
Introduction to Progressive Web Apps / Meet Magento PL 2018
Introduction to Progressive Web Apps / Meet Magento PL 2018Introduction to Progressive Web Apps / Meet Magento PL 2018
Introduction to Progressive Web Apps / Meet Magento PL 2018
Filip Rakowski
 
The Big Cloud native FaaS Lebowski
The Big Cloud native FaaS LebowskiThe Big Cloud native FaaS Lebowski
The Big Cloud native FaaS Lebowski
QAware GmbH
 
Workshop: Introduction to Web Components & Polymer
Workshop: Introduction to Web Components & Polymer Workshop: Introduction to Web Components & Polymer
Workshop: Introduction to Web Components & Polymer
John Riviello
 
Keypoints html5
Keypoints html5Keypoints html5
Keypoints html5
dynamis
 
Pain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr SugakPain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr Sugak
Sigma Software
 
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG
🎤 Hanno Embregts 🎸
 
Ionic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application DevelopmentIonic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application Development
Justin James
 
Encode polkadot club
Encode polkadot club  Encode polkadot club
Encode polkadot club
Vanessa Lošić
 
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
Marco Cedaro
 
Enhance SharePoint with Responsive Web Design
Enhance SharePoint with Responsive Web DesignEnhance SharePoint with Responsive Web Design
Enhance SharePoint with Responsive Web Design
Eric Overfield
 

Similar to Performance optimization of vue.js apps with modern js (20)

Filip Rakowski "Web Performance in modern JavaScript world"
Filip Rakowski "Web Performance in modern JavaScript world"Filip Rakowski "Web Performance in modern JavaScript world"
Filip Rakowski "Web Performance in modern JavaScript world"
 
Web Frameworks of the Future
Web Frameworks of the FutureWeb Frameworks of the Future
Web Frameworks of the Future
 
Long life to vagrant… Vagrant is dead
Long life to vagrant… Vagrant is deadLong life to vagrant… Vagrant is dead
Long life to vagrant… Vagrant is dead
 
"You’re probably using Lighthouse wrong: How do we misuse the most common too...
"You’re probably using Lighthouse wrong: How do we misuse the most common too..."You’re probably using Lighthouse wrong: How do we misuse the most common too...
"You’re probably using Lighthouse wrong: How do we misuse the most common too...
 
FFWD.PRO - It's not you, It's me (or how to avoid being coupled with a Javasc...
FFWD.PRO - It's not you, It's me (or how to avoid being coupled with a Javasc...FFWD.PRO - It's not you, It's me (or how to avoid being coupled with a Javasc...
FFWD.PRO - It's not you, It's me (or how to avoid being coupled with a Javasc...
 
Refactoring to Go modules: why and how
Refactoring to Go modules: why and howRefactoring to Go modules: why and how
Refactoring to Go modules: why and how
 
Phonegap 1.0
Phonegap 1.0Phonegap 1.0
Phonegap 1.0
 
Web Components: The Future of Web Development is Here
Web Components: The Future of Web Development is HereWeb Components: The Future of Web Development is Here
Web Components: The Future of Web Development is Here
 
Practical WebAssembly with Apex, wasmRS, and nanobus
Practical WebAssembly with Apex, wasmRS, and nanobusPractical WebAssembly with Apex, wasmRS, and nanobus
Practical WebAssembly with Apex, wasmRS, and nanobus
 
Selje_Amazing VFP2C32 Library.pdf
Selje_Amazing VFP2C32 Library.pdfSelje_Amazing VFP2C32 Library.pdf
Selje_Amazing VFP2C32 Library.pdf
 
Introduction to Progressive Web Apps / Meet Magento PL 2018
Introduction to Progressive Web Apps / Meet Magento PL 2018Introduction to Progressive Web Apps / Meet Magento PL 2018
Introduction to Progressive Web Apps / Meet Magento PL 2018
 
The Big Cloud native FaaS Lebowski
The Big Cloud native FaaS LebowskiThe Big Cloud native FaaS Lebowski
The Big Cloud native FaaS Lebowski
 
Workshop: Introduction to Web Components & Polymer
Workshop: Introduction to Web Components & Polymer Workshop: Introduction to Web Components & Polymer
Workshop: Introduction to Web Components & Polymer
 
Keypoints html5
Keypoints html5Keypoints html5
Keypoints html5
 
Pain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr SugakPain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr Sugak
 
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG
 
Ionic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application DevelopmentIonic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application Development
 
Encode polkadot club
Encode polkadot club  Encode polkadot club
Encode polkadot club
 
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
 
Enhance SharePoint with Responsive Web Design
Enhance SharePoint with Responsive Web DesignEnhance SharePoint with Responsive Web Design
Enhance SharePoint with Responsive Web Design
 

Recently uploaded

原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC
 
Search Result Showing My Post is Now Buried
Search Result Showing My Post is Now BuriedSearch Result Showing My Post is Now Buried
Search Result Showing My Post is Now Buried
Trish Parr
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
eutxy
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
ufdana
 
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
CIOWomenMagazine
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
Gal Baras
 
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
vmemo1
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
7 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 20247 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 2024
Danica Gill
 
Comptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guideComptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guide
GTProductions1
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
JeyaPerumal1
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
Rogerio Filho
 
Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027
harveenkaur52
 
2.Cellular Networks_The final stage of connectivity is achieved by segmenting...
2.Cellular Networks_The final stage of connectivity is achieved by segmenting...2.Cellular Networks_The final stage of connectivity is achieved by segmenting...
2.Cellular Networks_The final stage of connectivity is achieved by segmenting...
JeyaPerumal1
 
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
cuobya
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
Arif0071
 
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdfJAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
Javier Lasa
 
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
cuobya
 

Recently uploaded (20)

原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
APNIC Foundation, presented by Ellisha Heppner at the PNG DNS Forum 2024
 
Search Result Showing My Post is Now Buried
Search Result Showing My Post is Now BuriedSearch Result Showing My Post is Now Buried
Search Result Showing My Post is Now Buried
 
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
一比一原版(LBS毕业证)伦敦商学院毕业证成绩单专业办理
 
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
一比一原版(CSU毕业证)加利福尼亚州立大学毕业证成绩单专业办理
 
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
Internet of Things in Manufacturing: Revolutionizing Efficiency & Quality | C...
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
7 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 20247 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 2024
 
Comptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guideComptia N+ Standard Networking lesson guide
Comptia N+ Standard Networking lesson guide
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
 
Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027Italy Agriculture Equipment Market Outlook to 2027
Italy Agriculture Equipment Market Outlook to 2027
 
2.Cellular Networks_The final stage of connectivity is achieved by segmenting...
2.Cellular Networks_The final stage of connectivity is achieved by segmenting...2.Cellular Networks_The final stage of connectivity is achieved by segmenting...
2.Cellular Networks_The final stage of connectivity is achieved by segmenting...
 
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
可查真实(Monash毕业证)西澳大学毕业证成绩单退学买
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
 
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdfJAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
JAVIER LASA-EXPERIENCIA digital 1986-2024.pdf
 
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
 

Performance optimization of vue.js apps with modern js

Editor's Notes

  1. How many of you think performance is important?
  2. For those who did not raised their hands I will pretend that I’m smart and show some numbers to prove my point that web performance is extremely important.
  3. First of all as you can see only one second of waiting is enough for the user to make a mental context switch and potentially leave our website. Now let’s see how performance affects other numbers
  4. Given all this number we can assume a simple equation. Speed equals money. Do you agree?
  5. Now when I hope you’re convinced you how important web performance is let’s find main factors affecting it
  6. When we want some resource we need to request it and wait for resource. The bigger file is - the longer it takes to download it.
  7. Next JavaScript engine needs to parse it. Again the bigger file is - the longer it takes.
  8. Once parsing is finished and our JS engine created a nice AST that browser can work with it’s time to execute the code and guess what - the more code it’s to execute the longer it takes.
  9. Ok so it looks like the main factor influencing loading performance is file size. As a frontend developers we mostly can optimize the execution and parsing phase but we will see later that there are some things that we can do to improve response time. For now let’s focus on the area that we certainly can fully control.
  10. Let’s see what problems we can encounter by creating simple app
  11. It usually starts like this. An entry point with Vue attached and a root component. But over time the application grows
  12. We almost certainly will add a Vue-router. Following this we will add some routes, probably another 3rd party libs.
  13. Our initially downloaded JS bundle will grow with every module we add
  14. As we remember speed equals money so does it mean that more features equals less money?
  15. As you probably guessed it doesn’t To understand how to solve performance issues with growing bundle we need to understand how this bundle is constructed
  16. It appears that web pack under the hood is creating something called dependency graph. It’s just recursively checks the imports in JS modules and adds them to the graph starting from your entry point. To better understand this process lets see an example
  17. The problem with bundling all modules into one file is that we might not need some of the modules depending on current state of the application
  18. This is why webpack has feature called code splitting. It allows you to split your code into different bundles and load them on demand.
  19. Lazy loading is just loading this code splitter chunks on demand. So we are cutting some modules and loading them when they are needed
  20. We can tell webpack which parts of the code it should split by doing a dynamic import. Instead of a regular import dynamically imported module is an entry point for a completely new bundle. The bundle will be lazily loaded ONLY when this function is invoked.
  21. By dynamically importing routes we are making sure that only the visited route will be downloaded
  22. Code-splitter JS bundles generated by webpack will look like this.We have three bundles instead of one big file
  23. If you are using Nuxt you have this feature out of the box
  24. So rule number one… Per-route code splitting will give you more than any other lazy code splitting technique but we can do more
  25. There are still many things that are not needed right after user enters your website and can be loaded lazily
  26. Like popups
  27. Sidebars or any other off-screen components
  28. So rule number 2
  29. You can use v-if to conditionally load offscreen compoennts. V-if not true -> no render - no invocation - no download. It’s a great way to conditionally load components
  30. It appears that most of the 3rd party libs can also be loaded lazily.
  31. And the syntax is the same. Import function returns a promise with the lazily loaded lib
  32. When speaking about 3rd party libs there is a common approach to keep all of node modules in vendor bundle.
  33. Don’t do this. It’s much better to k keep 3rd party libs in route bundles or even better load them lazily whenever it’s possible. Otherwise users will download redundant code
  34. You’ll probably say ‚Hey Filip it leads to code duplication aren;’t vendor bundles meant to prevent it?’
  35. What if we will have loads imported in two routes. How to deal with this duplication?
  36. Now the shared modules will be bundled into a separate file and therefore downloaded only once
  37. Staying in the 3rd party libs topic there are tons of them and not all of them are good for your use case, or good overall so choose them carefully
  38. There is a great website that can help you with choosing appropriate libraries - bundle phobia
  39. It will give you all the information on how adding some particular library will affect your apps performance
  40. what is even better - it will also suggest you alternatives so you can really choose the best option
  41. Previously I mentioned that as a frontend devs we don’t have influence on how fast the server responds but it turns out that there are some things that we can do to improve this part of the process
  42. We can reduce the number of network requests by making use of assets that we already downloaded
  43. And we can use SW for this. They work as a proxy between your client web app and server
  44. We are sending request to the service worker which proxies it to the network
  45. But it can also proxy this request to the cache if asset was previously downloaded and respond almost instantly. Service Worker cache persists even when browser has been closed.
  46. You can either install Vue-cli PWA plugin for this
  47. ..or Nuxt PWA module
  48. In both cases you will see cached data under application tab of your devtools. Of course you can configure it as you wish
  49. We can make use of prefetching
  50. Which is just downloading assets before they are needed
  51. So rule number 5
  52. We can explicitly tell which chunks of code we want to prefetch with web pack magic comments that will dynamically add prefetch link to the head of our application
  53. Or use more general solutions with regular expressions
  54. If you are using Vue-cli 3 it’s prefetching code-splitter chunks out of the box
  55. If you are using Vue-cli 3 it’s prefetching code-splitter chunks out of the box
  56. Ok we learned a lot about performance optimization but it’s equally important to know where to optimize and measure our results.
  57. You can use devtools „coevrage” tool to see how much of the shipped code was actually executed
  58. You can also use Webpack Bundle Analyzer to actually see the size of your modules. This one is a must-have.
  59. …and instalation is extremely easy
  60. You can use ‚bundlesize’ package to make sure that you are not exceeding the reasonable size of the package.
  61. ..it also has a very nice GitHub integration
  62. And you can use import cost plugin to keep track of size of your imports