SlideShare uma empresa Scribd logo
1 de 61
© 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!

Mais conteúdo relacionado

Mais procurados

introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3 ArezooKmn
 
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 thingJoonas Lehtonen
 
Vue.js
Vue.jsVue.js
Vue.jsBADR
 
Introduction to VueJS & Vuex
Introduction to VueJS & VuexIntroduction to VueJS & Vuex
Introduction to VueJS & VuexBernd Alter
 
Nuxt.JS Introdruction
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS IntrodructionDavid Ličen
 
Vue Introduction
Vue IntroductionVue Introduction
Vue IntroductionElad Gasner
 
Drupal point of vue
Drupal point of vueDrupal point of vue
Drupal point of vueDavid Ličen
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJsTudor Barbu
 
Intro to vue.js
Intro to vue.jsIntro to vue.js
Intro to vue.jsTechMagic
 
Vuejs getting-started - Extended Version
Vuejs getting-started - Extended VersionVuejs getting-started - Extended Version
Vuejs getting-started - Extended VersionMurat Doğan
 
VueJS Introduction
VueJS IntroductionVueJS Introduction
VueJS IntroductionDavid 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 + TypeScriptKaty 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 VueJSdanpastori
 

Mais procurados (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
 

Semelhante a 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 nubeMarcia Villalba
 
Innovate - Breaking Down The Monolith
Innovate - Breaking Down The MonolithInnovate - Breaking Down The Monolith
Innovate - Breaking Down The MonolithShouvikKnightmare
 
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 2020Boaz 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 CDKCasey Lee
 
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 S3Chris Munns
 
5 incredible (and uncommon) serverless patterns
5 incredible (and uncommon) serverless patterns5 incredible (and uncommon) serverless patterns
5 incredible (and uncommon) serverless patternsDavidVictoria12
 
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.pptxJames 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 blocksCobus Bernard
 
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 FargateAmazon Web Services
 
The Business Benefits of GitOps
The Business Benefits of GitOpsThe Business Benefits of GitOps
The Business Benefits of GitOpsVMware Tanzu
 
Introducing AWS DeepRacer: David Smith
Introducing AWS DeepRacer: David SmithIntroducing AWS DeepRacer: David Smith
Introducing AWS DeepRacer: David SmithAWSCOMSUM
 
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 ContainersCobus 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 CloudFormationSubhamay 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 ManagementSujay Pillai
 
Operate Containers with AWS Copilot
Operate Containers with AWS CopilotOperate Containers with AWS Copilot
Operate Containers with AWS CopilotDevOps Indonesia
 
AWS DevDay Berlin - Automating building blocks choices you will face with con...
AWS DevDay Berlin - Automating building blocks choices you will face with con...AWS DevDay Berlin - Automating building blocks choices you will face with con...
AWS DevDay Berlin - Automating building blocks choices you will face with con...Cobus Bernard
 

Semelhante a 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
 
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
 
AWS DevDay Berlin - Automating building blocks choices you will face with con...
AWS DevDay Berlin - Automating building blocks choices you will face with con...AWS DevDay Berlin - Automating building blocks choices you will face with con...
AWS DevDay Berlin - Automating building blocks choices you will face with con...
 

Último

Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniquesugginaramesh
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxPurva Nikam
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 

Último (20)

Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniques
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 

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!