SlideShare a Scribd company logo
© 2021, Amazon Web Services, Inc. or its Affiliates.
Norbert Nader
Front-end Engineer @ Amazon Web Services
June 9, 2021
Vue.js
Code splitting and lazy loading
© 2021, Amazon Web Services, Inc. or its Affiliates.
The plan for this talk
• What is code splitting and lazy loading?
• Applying code splitting and lazy loading techniques in aVue.js app
• How can we measure performance?
• Moving aVue.js app to theAWS Cloud
• Takeaways
• Q&A
© 2021, Amazon Web Services, Inc. or its Affiliates.
Let’s get started!
What is code splitting and lazy loading?
© 2021, Amazon Web Services, Inc. or its Affiliates.
Webpack's definition of code splitting and lazy loading
“Code splitting is one of the most compelling features of webpack.
This feature allows you to split your code into various bundles which
can then be loaded on demand or in parallel. It can be used to
achieve smaller bundles and control resource load prioritization
which, if used correctly, can have a major impact on load time.”
https://webpack.js.org/guides/code-splitting
“Lazy, or "on demand", loading is a great way to optimize your site
or application. This practice essentially involves splitting your code
at logical breakpoints, and then loading it once the user has done
something that requires, or will require, a new block of code.This
speeds up the initial load of the application and lightens its overall
weight as some blocks may never even be loaded.”
https://webpack.js.org/guides/lazy-loading
index.js
bundle-0.js
bundle-1.js
bundle-2.js
index.js
© 2021, Amazon Web Services, Inc. or its Affiliates.
Code splitting
using the webpack config
© 2021, Amazon Web Services, Inc. or its Affiliates.
Code splitting CSS using MiniCssExtractPlugin
© 2021, Amazon Web Services, Inc. or its Affiliates.
Lazy loading
using dynamic imports
© 2021, Amazon Web Services, Inc. or its Affiliates.
Dynamically loading aVue.js component
Before
After
© 2021, Amazon Web Services, Inc. or its Affiliates.
How it’s done inVue.js
© 2021, Amazon Web Services, Inc. or its Affiliates.
Start with installingVue CLI
Instant Prototyping
Example
© 2021, Amazon Web Services, Inc. or its Affiliates.
Then install the dependencies
package.json
© 2021, Amazon Web Services, Inc. or its Affiliates.
Create aVue.js app
router.js app.js
App.vue
© 2021, Amazon Web Services, Inc. or its Affiliates.
Before code splitting
and lazy loading…
© 2021, Amazon Web Services, Inc. or its Affiliates.
Chrome DevTools
© 2021, Amazon Web Services, Inc. or its Affiliates.
Let’s add code splitting for CSS!
vue.config.js App.vue
© 2021, Amazon Web Services, Inc. or its Affiliates.
Let’s lazy load the routes!
router.js
© 2021, Amazon Web Services, Inc. or its Affiliates.
Let’s lazy load a component!
About.vue
© 2021, Amazon Web Services, Inc. or its Affiliates.
After code splitting
and lazy loading
© 2021, Amazon Web Services, Inc. or its Affiliates.
Chrome DevTools
© 2021, Amazon Web Services, Inc. or its Affiliates.
Chrome DevTools
© 2021, Amazon Web Services, Inc. or its Affiliates.
Prefetching and Preloading resources
vue.config.js About.vue
router.js
© 2021, Amazon Web Services, Inc. or its Affiliates.
Analyzing the bundles
vue.config.js
© 2021, Amazon Web Services, Inc. or its Affiliates.
Code splitting with SSR
© 2021, Amazon Web Services, Inc. or its Affiliates.
Install server renderer and express
© 2021, Amazon Web Services, Inc. or its Affiliates.
Install webpack plugins
© 2021, Amazon Web Services, Inc. or its Affiliates.
package.json
© 2021, Amazon Web Services, Inc. or its Affiliates.
vue.config.js
© 2021, Amazon Web Services, Inc. or its Affiliates.
app.js
© 2021, Amazon Web Services, Inc. or its Affiliates.
entry-server.js
© 2021, Amazon Web Services, Inc. or its Affiliates.
entry-client.js
© 2021, Amazon Web Services, Inc. or its Affiliates.
router.js
© 2021, Amazon Web Services, Inc. or its Affiliates.
server.js
© 2021, Amazon Web Services, Inc. or its Affiliates.
After code splitting
with SSR…
© 2021, Amazon Web Services, Inc. or its Affiliates.
Performance after SSR
© 2021, Amazon Web Services, Inc. or its Affiliates.
Performance after SSR
© 2021, Amazon Web Services, Inc. or its Affiliates.
Measuring performance
© 2021, Amazon Web Services, Inc. or its Affiliates.
Logging metrics
App.vue
© 2021, Amazon Web Services, Inc. or its Affiliates.
Moving your app
to the AWS Cloud
© 2021, Amazon Web Services, Inc. or its Affiliates.
Infrastructure
SSR function
CDN Assets (JS, CSS, etc.)
/log
Logs
Canaries
Brower request app page or logs
metrics
Metrics function
App endpoint
Client
Client assets
HTML generated on the
Node.js lambda
The generated html has script and
link tags pointing to asset
Point all traffic i.e. / to SSR
Put metrics e.g. TTI
Canaries hit page
Scripts returned from SSR fetch
code split bundles
User
© 2021, Amazon Web Services, Inc. or its Affiliates.
Install AWS CLI and SAM
https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install-mac.html
© 2021, Amazon Web Services, Inc. or its Affiliates.
Create an Amazon S3 bucket for our assets
© 2021, Amazon Web Services, Inc. or its Affiliates.
Upload assets to our Amazon S3 bucket
asset-uploader.sh
© 2021, Amazon Web Services, Inc. or its Affiliates.
Point Amazon CloudFront to Amazon S3 bucket
© 2021, Amazon Web Services, Inc. or its Affiliates.
Create an OAI for Amazon CloudFront distribution
© 2021, Amazon Web Services, Inc. or its Affiliates.
Restrict access to private Amazon S3 bucket
cf-distribution.json
© 2021, Amazon Web Services, Inc. or its Affiliates.
Update Amazon S3 bucket policy
policy.json
© 2021, Amazon Web Services, Inc. or its Affiliates.
Update vue.config.js to point to Amazon CloudFront
vue.config.js
© 2021, Amazon Web Services, Inc. or its Affiliates.
Create a Node.js function with AWS Lambda
ssr-lambda.js template.yaml
© 2021, Amazon Web Services, Inc. or its Affiliates.
Testing AWS Lambda locally
package.json
© 2021, Amazon Web Services, Inc. or its Affiliates.
Deploying our app to production
© 2021, Amazon Web Services, Inc. or its Affiliates.
Production
© 2021, Amazon Web Services, Inc. or its Affiliates.
Logging metrics to Amazon CloudWatch
package.json
metrics-lambda.js
© 2021, Amazon Web Services, Inc. or its Affiliates.
Deploying the metrics AWS Lambda
template.yaml
© 2021, Amazon Web Services, Inc. or its Affiliates.
Update our logger
logger.js
© 2021, Amazon Web Services, Inc. or its Affiliates.
Setting up dashboards and alarms
© 2021, Amazon Web Services, Inc. or its Affiliates.
Running canaries
© 2021, Amazon Web Services, Inc. or its Affiliates.
CI/CD Pipeline
Develop code
Build and deploy Monitor and test
© 2021, Amazon Web Services, Inc. or its Affiliates.
Takeaways
• We learned what is code splitting and lazy loading
• We applied code splitting and lazy loading techniques in aVue.js app
• We learned how we can measure performance
• We moved aVue.js app to theAWS cloud
© 2021, Amazon Web Services, Inc. or its Affiliates.
Resources
• https://webpack.js.org/concepts
• https://cli.vuejs.org/guide/
• https://v3.vuejs.org/guide/introduction.html
• https://router.vuejs.org/guide/
• https://docs.aws.amazon.com
• https://www.npmjs.com/
• https://developer.mozilla.org/
• https://developers.google.com/web
• https://web.dev/
This project https://github.com/NorbertNader/vue-aws-starter-kit
© 2021, Amazon Web Services, Inc. or its Affiliates.
Q&A
Norbert Nader
© 2021, Amazon Web Services, Inc. or its Affiliates.
ThankYou!

More Related Content

What's hot

introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3
ArezooKmn
 
Why Vue.js?
Why Vue.js?Why Vue.js?
Why Vue.js?
Jonathan Goode
 
Vue.js is boring - and that's a good thing
Vue.js is boring - and that's a good thingVue.js is boring - and that's a good thing
Vue.js is boring - and that's a good thing
Joonas Lehtonen
 
Vue.js
Vue.jsVue.js
Vue.js
BADR
 
Introduction to VueJS & Vuex
Introduction to VueJS & VuexIntroduction to VueJS & Vuex
Introduction to VueJS & Vuex
Bernd Alter
 
Nuxt.JS Introdruction
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS Introdruction
David Ličen
 
Vue Introduction
Vue IntroductionVue Introduction
Vue Introduction
Elad Gasner
 
Drupal point of vue
Drupal point of vueDrupal point of vue
Drupal point of vue
David Ličen
 
Vuex
VuexVuex
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
Tudor Barbu
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.js
TechMagic
 
Vue business first
Vue business firstVue business first
Vue business first
Vitalii Ratyshnyi
 
Vuejs getting-started - Extended Version
Vuejs getting-started - Extended VersionVuejs getting-started - Extended Version
Vuejs getting-started - Extended Version
Murat Doğan
 
Love at first Vue
Love at first VueLove at first Vue
Love at first Vue
Dalibor Gogic
 
Vue JS Intro
Vue JS IntroVue JS Intro
Vue JS Intro
Muhammad Rizki Rijal
 
VueJS Introduction
VueJS IntroductionVueJS Introduction
VueJS Introduction
David Ličen
 
Deep dive into Vue.js
Deep dive into Vue.jsDeep dive into Vue.js
Deep dive into Vue.js
선협 이
 
How to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScriptHow to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScript
Katy Slemon
 
Building a Single Page Application with VueJS
Building a Single Page Application with VueJSBuilding a Single Page Application with VueJS
Building a Single Page Application with VueJS
danpastori
 
Vue, vue router, vuex
Vue, vue router, vuexVue, vue router, vuex
Vue, vue router, vuex
Samundra khatri
 

What's hot (20)

introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3
 
Why Vue.js?
Why Vue.js?Why Vue.js?
Why Vue.js?
 
Vue.js is boring - and that's a good thing
Vue.js is boring - and that's a good thingVue.js is boring - and that's a good thing
Vue.js is boring - and that's a good thing
 
Vue.js
Vue.jsVue.js
Vue.js
 
Introduction to VueJS & Vuex
Introduction to VueJS & VuexIntroduction to VueJS & Vuex
Introduction to VueJS & Vuex
 
Nuxt.JS Introdruction
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS Introdruction
 
Vue Introduction
Vue IntroductionVue Introduction
Vue Introduction
 
Drupal point of vue
Drupal point of vueDrupal point of vue
Drupal point of vue
 
Vuex
VuexVuex
Vuex
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.js
 
Vue business first
Vue business firstVue business first
Vue business first
 
Vuejs getting-started - Extended Version
Vuejs getting-started - Extended VersionVuejs getting-started - Extended Version
Vuejs getting-started - Extended Version
 
Love at first Vue
Love at first VueLove at first Vue
Love at first Vue
 
Vue JS Intro
Vue JS IntroVue JS Intro
Vue JS Intro
 
VueJS Introduction
VueJS IntroductionVueJS Introduction
VueJS Introduction
 
Deep dive into Vue.js
Deep dive into Vue.jsDeep dive into Vue.js
Deep dive into Vue.js
 
How to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScriptHow to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScript
 
Building a Single Page Application with VueJS
Building a Single Page Application with VueJSBuilding a Single Page Application with VueJS
Building a Single Page Application with VueJS
 
Vue, vue router, vuex
Vue, vue router, vuexVue, vue router, vuex
Vue, vue router, vuex
 

Similar to Vue presentation

20210608 - Desarrollo de aplicaciones en la nube
20210608 - Desarrollo de aplicaciones en la nube20210608 - Desarrollo de aplicaciones en la nube
20210608 - Desarrollo de aplicaciones en la nube
Marcia Villalba
 
Innovate - Breaking Down The Monolith
Innovate - Breaking Down The MonolithInnovate - Breaking Down The Monolith
Innovate - Breaking Down The Monolith
ShouvikKnightmare
 
What can you do with Serverless in 2020
What can you do with Serverless in 2020What can you do with Serverless in 2020
What can you do with Serverless in 2020
Boaz Ziniman
 
20201013 - Serverless Architecture Conference - How to migrate your existing ...
20201013 - Serverless Architecture Conference - How to migrate your existing ...20201013 - Serverless Architecture Conference - How to migrate your existing ...
20201013 - Serverless Architecture Conference - How to migrate your existing ...
Marcia Villalba
 
AWS Summit DC 2021: Improve the developer experience with AWS CDK
AWS Summit DC 2021: Improve the developer experience with AWS CDKAWS Summit DC 2021: Improve the developer experience with AWS CDK
AWS Summit DC 2021: Improve the developer experience with AWS CDK
Casey Lee
 
EFS_Integration.pdf
EFS_Integration.pdfEFS_Integration.pdf
EFS_Integration.pdf
Suman Debnath
 
AWS re:Invent serverless recap day: Whats new with AWS StepFunctions. - Expre...
AWS re:Invent serverless recap day: Whats new with AWS StepFunctions. - Expre...AWS re:Invent serverless recap day: Whats new with AWS StepFunctions. - Expre...
AWS re:Invent serverless recap day: Whats new with AWS StepFunctions. - Expre...
⛷️ Ben Smith
 
Building serverless applications with Amazon S3
Building serverless applications with Amazon S3Building serverless applications with Amazon S3
Building serverless applications with Amazon S3
Chris Munns
 
5 incredible (and uncommon) serverless patterns
5 incredible (and uncommon) serverless patterns5 incredible (and uncommon) serverless patterns
5 incredible (and uncommon) serverless patterns
DavidVictoria12
 
20 ways event-driven architectures can improve your development - Copy.pptx
20 ways event-driven architectures can improve your development - Copy.pptx20 ways event-driven architectures can improve your development - Copy.pptx
20 ways event-driven architectures can improve your development - Copy.pptx
James Beswick
 
AWS DevDay Vienna - Automating building blocks choices you will face with con...
AWS DevDay Vienna - Automating building blocks choices you will face with con...AWS DevDay Vienna - Automating building blocks choices you will face with con...
AWS DevDay Vienna - Automating building blocks choices you will face with con...
Cobus Bernard
 
DevConfZA 2020 : Automating your cloud: What are the building blocks
DevConfZA 2020 : Automating your cloud: What are the building blocksDevConfZA 2020 : Automating your cloud: What are the building blocks
DevConfZA 2020 : Automating your cloud: What are the building blocks
Cobus Bernard
 
PDF_Slide__Memodernisasi_aplikasi_Microsoft_Anda_dengan_cepat_di_AWS.pdf
PDF_Slide__Memodernisasi_aplikasi_Microsoft_Anda_dengan_cepat_di_AWS.pdfPDF_Slide__Memodernisasi_aplikasi_Microsoft_Anda_dengan_cepat_di_AWS.pdf
PDF_Slide__Memodernisasi_aplikasi_Microsoft_Anda_dengan_cepat_di_AWS.pdf
Ropiudin5
 
CI/CD with AWS Developer Tools and Fargate
CI/CD with AWS Developer Tools and FargateCI/CD with AWS Developer Tools and Fargate
CI/CD with AWS Developer Tools and Fargate
Amazon Web Services
 
The Business Benefits of GitOps
The Business Benefits of GitOpsThe Business Benefits of GitOps
The Business Benefits of GitOps
VMware Tanzu
 
Introducing AWS DeepRacer: David Smith
Introducing AWS DeepRacer: David SmithIntroducing AWS DeepRacer: David Smith
Introducing AWS DeepRacer: David Smith
AWSCOMSUM
 
AWS SSA Webinar 12 - Getting started on AWS with Containers
AWS SSA Webinar 12 - Getting started on AWS with ContainersAWS SSA Webinar 12 - Getting started on AWS with Containers
AWS SSA Webinar 12 - Getting started on AWS with Containers
Cobus Bernard
 
Creating a RDS MySQL instance from AWS Console and CloudFormation
Creating a RDS MySQL instance from AWS Console and CloudFormationCreating a RDS MySQL instance from AWS Console and CloudFormation
Creating a RDS MySQL instance from AWS Console and CloudFormation
Subhamay Bhattacharyya
 
Frome Code to Cloud: Exploring AWS CDK for Infrastructure Management
Frome Code to Cloud: Exploring AWS CDK for Infrastructure ManagementFrome Code to Cloud: Exploring AWS CDK for Infrastructure Management
Frome Code to Cloud: Exploring AWS CDK for Infrastructure Management
Sujay Pillai
 
Operate Containers with AWS Copilot
Operate Containers with AWS CopilotOperate Containers with AWS Copilot
Operate Containers with AWS Copilot
DevOps Indonesia
 

Similar to Vue presentation (20)

20210608 - Desarrollo de aplicaciones en la nube
20210608 - Desarrollo de aplicaciones en la nube20210608 - Desarrollo de aplicaciones en la nube
20210608 - Desarrollo de aplicaciones en la nube
 
Innovate - Breaking Down The Monolith
Innovate - Breaking Down The MonolithInnovate - Breaking Down The Monolith
Innovate - Breaking Down The Monolith
 
What can you do with Serverless in 2020
What can you do with Serverless in 2020What can you do with Serverless in 2020
What can you do with Serverless in 2020
 
20201013 - Serverless Architecture Conference - How to migrate your existing ...
20201013 - Serverless Architecture Conference - How to migrate your existing ...20201013 - Serverless Architecture Conference - How to migrate your existing ...
20201013 - Serverless Architecture Conference - How to migrate your existing ...
 
AWS Summit DC 2021: Improve the developer experience with AWS CDK
AWS Summit DC 2021: Improve the developer experience with AWS CDKAWS Summit DC 2021: Improve the developer experience with AWS CDK
AWS Summit DC 2021: Improve the developer experience with AWS CDK
 
EFS_Integration.pdf
EFS_Integration.pdfEFS_Integration.pdf
EFS_Integration.pdf
 
AWS re:Invent serverless recap day: Whats new with AWS StepFunctions. - Expre...
AWS re:Invent serverless recap day: Whats new with AWS StepFunctions. - Expre...AWS re:Invent serverless recap day: Whats new with AWS StepFunctions. - Expre...
AWS re:Invent serverless recap day: Whats new with AWS StepFunctions. - Expre...
 
Building serverless applications with Amazon S3
Building serverless applications with Amazon S3Building serverless applications with Amazon S3
Building serverless applications with Amazon S3
 
5 incredible (and uncommon) serverless patterns
5 incredible (and uncommon) serverless patterns5 incredible (and uncommon) serverless patterns
5 incredible (and uncommon) serverless patterns
 
20 ways event-driven architectures can improve your development - Copy.pptx
20 ways event-driven architectures can improve your development - Copy.pptx20 ways event-driven architectures can improve your development - Copy.pptx
20 ways event-driven architectures can improve your development - Copy.pptx
 
AWS DevDay Vienna - Automating building blocks choices you will face with con...
AWS DevDay Vienna - Automating building blocks choices you will face with con...AWS DevDay Vienna - Automating building blocks choices you will face with con...
AWS DevDay Vienna - Automating building blocks choices you will face with con...
 
DevConfZA 2020 : Automating your cloud: What are the building blocks
DevConfZA 2020 : Automating your cloud: What are the building blocksDevConfZA 2020 : Automating your cloud: What are the building blocks
DevConfZA 2020 : Automating your cloud: What are the building blocks
 
PDF_Slide__Memodernisasi_aplikasi_Microsoft_Anda_dengan_cepat_di_AWS.pdf
PDF_Slide__Memodernisasi_aplikasi_Microsoft_Anda_dengan_cepat_di_AWS.pdfPDF_Slide__Memodernisasi_aplikasi_Microsoft_Anda_dengan_cepat_di_AWS.pdf
PDF_Slide__Memodernisasi_aplikasi_Microsoft_Anda_dengan_cepat_di_AWS.pdf
 
CI/CD with AWS Developer Tools and Fargate
CI/CD with AWS Developer Tools and FargateCI/CD with AWS Developer Tools and Fargate
CI/CD with AWS Developer Tools and Fargate
 
The Business Benefits of GitOps
The Business Benefits of GitOpsThe Business Benefits of GitOps
The Business Benefits of GitOps
 
Introducing AWS DeepRacer: David Smith
Introducing AWS DeepRacer: David SmithIntroducing AWS DeepRacer: David Smith
Introducing AWS DeepRacer: David Smith
 
AWS SSA Webinar 12 - Getting started on AWS with Containers
AWS SSA Webinar 12 - Getting started on AWS with ContainersAWS SSA Webinar 12 - Getting started on AWS with Containers
AWS SSA Webinar 12 - Getting started on AWS with Containers
 
Creating a RDS MySQL instance from AWS Console and CloudFormation
Creating a RDS MySQL instance from AWS Console and CloudFormationCreating a RDS MySQL instance from AWS Console and CloudFormation
Creating a RDS MySQL instance from AWS Console and CloudFormation
 
Frome Code to Cloud: Exploring AWS CDK for Infrastructure Management
Frome Code to Cloud: Exploring AWS CDK for Infrastructure ManagementFrome Code to Cloud: Exploring AWS CDK for Infrastructure Management
Frome Code to Cloud: Exploring AWS CDK for Infrastructure Management
 
Operate Containers with AWS Copilot
Operate Containers with AWS CopilotOperate Containers with AWS Copilot
Operate Containers with AWS Copilot
 

Recently uploaded

哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
Exception Handling notes in java exception
Exception Handling notes in java exceptionException Handling notes in java exception
Exception Handling notes in java exception
Ratnakar Mikkili
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
Self-Control of Emotions by Slidesgo.pptx
Self-Control of Emotions by Slidesgo.pptxSelf-Control of Emotions by Slidesgo.pptx
Self-Control of Emotions by Slidesgo.pptx
iemerc2024
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
zwunae
 
This is my Environmental physics presentation
This is my Environmental physics presentationThis is my Environmental physics presentation
This is my Environmental physics presentation
ZainabHashmi17
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
Low power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniquesLow power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniques
nooriasukmaningtyas
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
Adaptive synchronous sliding control for a robot manipulator based on neural ...
Adaptive synchronous sliding control for a robot manipulator based on neural ...Adaptive synchronous sliding control for a robot manipulator based on neural ...
Adaptive synchronous sliding control for a robot manipulator based on neural ...
IJECEIAES
 

Recently uploaded (20)

哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
Exception Handling notes in java exception
Exception Handling notes in java exceptionException Handling notes in java exception
Exception Handling notes in java exception
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
Self-Control of Emotions by Slidesgo.pptx
Self-Control of Emotions by Slidesgo.pptxSelf-Control of Emotions by Slidesgo.pptx
Self-Control of Emotions by Slidesgo.pptx
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单专业办理
 
This is my Environmental physics presentation
This is my Environmental physics presentationThis is my Environmental physics presentation
This is my Environmental physics presentation
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
Low power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniquesLow power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniques
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
Adaptive synchronous sliding control for a robot manipulator based on neural ...
Adaptive synchronous sliding control for a robot manipulator based on neural ...Adaptive synchronous sliding control for a robot manipulator based on neural ...
Adaptive synchronous sliding control for a robot manipulator based on neural ...
 

Vue presentation

  • 1. © 2021, Amazon Web Services, Inc. or its Affiliates. Norbert Nader Front-end Engineer @ Amazon Web Services June 9, 2021 Vue.js Code splitting and lazy loading
  • 2. © 2021, Amazon Web Services, Inc. or its Affiliates. The plan for this talk • What is code splitting and lazy loading? • Applying code splitting and lazy loading techniques in aVue.js app • How can we measure performance? • Moving aVue.js app to theAWS Cloud • Takeaways • Q&A
  • 3. © 2021, Amazon Web Services, Inc. or its Affiliates. Let’s get started! What is code splitting and lazy loading?
  • 4. © 2021, Amazon Web Services, Inc. or its Affiliates. Webpack's definition of code splitting and lazy loading “Code splitting is one of the most compelling features of webpack. This feature allows you to split your code into various bundles which can then be loaded on demand or in parallel. It can be used to achieve smaller bundles and control resource load prioritization which, if used correctly, can have a major impact on load time.” https://webpack.js.org/guides/code-splitting “Lazy, or "on demand", loading is a great way to optimize your site or application. This practice essentially involves splitting your code at logical breakpoints, and then loading it once the user has done something that requires, or will require, a new block of code.This speeds up the initial load of the application and lightens its overall weight as some blocks may never even be loaded.” https://webpack.js.org/guides/lazy-loading index.js bundle-0.js bundle-1.js bundle-2.js index.js
  • 5. © 2021, Amazon Web Services, Inc. or its Affiliates. Code splitting using the webpack config
  • 6. © 2021, Amazon Web Services, Inc. or its Affiliates. Code splitting CSS using MiniCssExtractPlugin
  • 7. © 2021, Amazon Web Services, Inc. or its Affiliates. Lazy loading using dynamic imports
  • 8. © 2021, Amazon Web Services, Inc. or its Affiliates. Dynamically loading aVue.js component Before After
  • 9. © 2021, Amazon Web Services, Inc. or its Affiliates. How it’s done inVue.js
  • 10. © 2021, Amazon Web Services, Inc. or its Affiliates. Start with installingVue CLI Instant Prototyping Example
  • 11. © 2021, Amazon Web Services, Inc. or its Affiliates. Then install the dependencies package.json
  • 12. © 2021, Amazon Web Services, Inc. or its Affiliates. Create aVue.js app router.js app.js App.vue
  • 13. © 2021, Amazon Web Services, Inc. or its Affiliates. Before code splitting and lazy loading…
  • 14. © 2021, Amazon Web Services, Inc. or its Affiliates. Chrome DevTools
  • 15. © 2021, Amazon Web Services, Inc. or its Affiliates. Let’s add code splitting for CSS! vue.config.js App.vue
  • 16. © 2021, Amazon Web Services, Inc. or its Affiliates. Let’s lazy load the routes! router.js
  • 17. © 2021, Amazon Web Services, Inc. or its Affiliates. Let’s lazy load a component! About.vue
  • 18. © 2021, Amazon Web Services, Inc. or its Affiliates. After code splitting and lazy loading
  • 19. © 2021, Amazon Web Services, Inc. or its Affiliates. Chrome DevTools
  • 20. © 2021, Amazon Web Services, Inc. or its Affiliates. Chrome DevTools
  • 21. © 2021, Amazon Web Services, Inc. or its Affiliates. Prefetching and Preloading resources vue.config.js About.vue router.js
  • 22. © 2021, Amazon Web Services, Inc. or its Affiliates. Analyzing the bundles vue.config.js
  • 23. © 2021, Amazon Web Services, Inc. or its Affiliates. Code splitting with SSR
  • 24. © 2021, Amazon Web Services, Inc. or its Affiliates. Install server renderer and express
  • 25. © 2021, Amazon Web Services, Inc. or its Affiliates. Install webpack plugins
  • 26. © 2021, Amazon Web Services, Inc. or its Affiliates. package.json
  • 27. © 2021, Amazon Web Services, Inc. or its Affiliates. vue.config.js
  • 28. © 2021, Amazon Web Services, Inc. or its Affiliates. app.js
  • 29. © 2021, Amazon Web Services, Inc. or its Affiliates. entry-server.js
  • 30. © 2021, Amazon Web Services, Inc. or its Affiliates. entry-client.js
  • 31. © 2021, Amazon Web Services, Inc. or its Affiliates. router.js
  • 32. © 2021, Amazon Web Services, Inc. or its Affiliates. server.js
  • 33. © 2021, Amazon Web Services, Inc. or its Affiliates. After code splitting with SSR…
  • 34. © 2021, Amazon Web Services, Inc. or its Affiliates. Performance after SSR
  • 35. © 2021, Amazon Web Services, Inc. or its Affiliates. Performance after SSR
  • 36. © 2021, Amazon Web Services, Inc. or its Affiliates. Measuring performance
  • 37. © 2021, Amazon Web Services, Inc. or its Affiliates. Logging metrics App.vue
  • 38. © 2021, Amazon Web Services, Inc. or its Affiliates. Moving your app to the AWS Cloud
  • 39. © 2021, Amazon Web Services, Inc. or its Affiliates. Infrastructure SSR function CDN Assets (JS, CSS, etc.) /log Logs Canaries Brower request app page or logs metrics Metrics function App endpoint Client Client assets HTML generated on the Node.js lambda The generated html has script and link tags pointing to asset Point all traffic i.e. / to SSR Put metrics e.g. TTI Canaries hit page Scripts returned from SSR fetch code split bundles User
  • 40. © 2021, Amazon Web Services, Inc. or its Affiliates. Install AWS CLI and SAM https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install-mac.html
  • 41. © 2021, Amazon Web Services, Inc. or its Affiliates. Create an Amazon S3 bucket for our assets
  • 42. © 2021, Amazon Web Services, Inc. or its Affiliates. Upload assets to our Amazon S3 bucket asset-uploader.sh
  • 43. © 2021, Amazon Web Services, Inc. or its Affiliates. Point Amazon CloudFront to Amazon S3 bucket
  • 44. © 2021, Amazon Web Services, Inc. or its Affiliates. Create an OAI for Amazon CloudFront distribution
  • 45. © 2021, Amazon Web Services, Inc. or its Affiliates. Restrict access to private Amazon S3 bucket cf-distribution.json
  • 46. © 2021, Amazon Web Services, Inc. or its Affiliates. Update Amazon S3 bucket policy policy.json
  • 47. © 2021, Amazon Web Services, Inc. or its Affiliates. Update vue.config.js to point to Amazon CloudFront vue.config.js
  • 48. © 2021, Amazon Web Services, Inc. or its Affiliates. Create a Node.js function with AWS Lambda ssr-lambda.js template.yaml
  • 49. © 2021, Amazon Web Services, Inc. or its Affiliates. Testing AWS Lambda locally package.json
  • 50. © 2021, Amazon Web Services, Inc. or its Affiliates. Deploying our app to production
  • 51. © 2021, Amazon Web Services, Inc. or its Affiliates. Production
  • 52. © 2021, Amazon Web Services, Inc. or its Affiliates. Logging metrics to Amazon CloudWatch package.json metrics-lambda.js
  • 53. © 2021, Amazon Web Services, Inc. or its Affiliates. Deploying the metrics AWS Lambda template.yaml
  • 54. © 2021, Amazon Web Services, Inc. or its Affiliates. Update our logger logger.js
  • 55. © 2021, Amazon Web Services, Inc. or its Affiliates. Setting up dashboards and alarms
  • 56. © 2021, Amazon Web Services, Inc. or its Affiliates. Running canaries
  • 57. © 2021, Amazon Web Services, Inc. or its Affiliates. CI/CD Pipeline Develop code Build and deploy Monitor and test
  • 58. © 2021, Amazon Web Services, Inc. or its Affiliates. Takeaways • We learned what is code splitting and lazy loading • We applied code splitting and lazy loading techniques in aVue.js app • We learned how we can measure performance • We moved aVue.js app to theAWS cloud
  • 59. © 2021, Amazon Web Services, Inc. or its Affiliates. Resources • https://webpack.js.org/concepts • https://cli.vuejs.org/guide/ • https://v3.vuejs.org/guide/introduction.html • https://router.vuejs.org/guide/ • https://docs.aws.amazon.com • https://www.npmjs.com/ • https://developer.mozilla.org/ • https://developers.google.com/web • https://web.dev/ This project https://github.com/NorbertNader/vue-aws-starter-kit
  • 60. © 2021, Amazon Web Services, Inc. or its Affiliates. Q&A Norbert Nader
  • 61. © 2021, Amazon Web Services, Inc. or its Affiliates. ThankYou!