SlideShare a Scribd company logo
1 of 22
Introduction
13 Dec, 2015
Goal of the discussion
Sharing knowledge of
web performance
Determination of our
Goal
What is web performance really mean?
Performance is the art of avoiding work. Really??
Yep, only if no one complains against that performance.
ACTION Expected Time (ms)
Load Under 1000ms
Response Under 100ms
Animation Under 16ms
Idle Maximize. Script chunked should not be
larger than 50ms
Expected Performance
LOAD
1. Critical content should be loaded under 1000ms
2. Showing an update (e.g showing a loader) if it takes more than 1000ms
3. It includes network latency time
What is critical content?
Let's go through how browser process response from webserver
1. Document Object Model (DOM)
2. CSS Object Model (CSSOM)
Bytes
Browser receives
bytes from server
Characters
Convert bytes to
character based on
specified encoding
Tokens
Tokenize characters to
tokens <html>,
</html>, <head>,
</head>
Nodes
Tokens are converted
to node e.g head,
body, div
DOM
Constructs THE DOM
DOM
Bytes
Browser receives
bytes from server
Characters
Convert bytes to
character based on
specified encoding
Tokens
Tokenize characters to
tokens <html>,
</html>, <head>,
</head>
Nodes
Tokens are converted
to node e.g head,
body, div
CSSOM
Constructs THE
CSSOM
CSSOM
DOM Tree Example
CSSOM Tree Example
DOM vs CSSOM
1. DOM and CSSOM are independent data structures.
2. Chrome DevTools Timeline allows us to capture and inspect the construction and processing costs
of DOM and CSSOM.
3. DOM and CSSOM construct RENDER TREE together
Render Tree
1. The DOM and CSSOM trees are combined to form the render tree.
2. Render tree contains only the nodes required to render the page. For example, node with css
display:none does not include inside render tree
Layout and Paint
1. Layout computes the exact position and size of each object.
2. Finally comes to Paint step that takes in the final render tree and renders the pixels to the screen.
1. Process HTML markup and build the DOM tree.
2. Process CSS markup and build the CSSOM tree.
3. Combine the DOM and CSSOM into a render tree.
4. Run layout on the render tree to compute geometry (width, height, position
etc) of each node.
5. Paint the individual nodes to the screen.
Feel the browser pain again :(
This full process is called critical rendering path
Rendering blocks
1. HTML file
2. CSS file unless explicitly used media type. e.g. media=”print” does not block in case of browser view
3. Javascript file unless explicitly declared as async. Because Javascript can modify DOM and
CSSOM
4. In a words, browser stop rendering until final DOM and CSSOM is completed
Noted that images are not rending block resource
Browser events
domContentLoaded - Fire when render tree is ready
domComplete - Fire when all resources including images are loading completed
Finally “Load” comes to end
Let's define the vocabulary we’ll be using to describe the critical rendering path:
Critical Resource: resource that may block initial rendering of the page. Example, html, js, css file
Critical Path Length: number of network roundtrips, or the total time required to fetch all of the critical
resources.
Critical Bytes: total amount of bytes required to get to first render of the page
All should be completed under 1000ms
Optimization of “Load” Step
1. Good server-end
2. Prefer async JavaScript resources
3. Avoid synchronous server calls e.g sync ajax request
4. Avoid long running JavaScript
5. Put CSS in the document head
6. Avoid CSS imports
Response
1. Should be under 100ms with input latency
2. Should be under 16ms without input latency
Animation
Each frame should be ready under 16ms
Why?
1. Because most of the device refresh rate is 60 frames/Sec i.e 60 FPS
2. Human eye does not differentiate frame change in this rate
3. 60 frames/Sec, so each frame = 1000ms/60 = ~16.5ms
4. Browser have to ready each frame by 16ms
5. Normally we get 10ms for each frame because browser has some
housekeeping to make ready the frame before sending to display device
JavaScript Style Layout Paint Composite
The pixel Pipeline
1. Browser have to follow each step for each frame depending on the changes
2. Sometimes browsers need to calculate same steps several times
3. Performance depends on how less brower work to complete the pixel pipeline
4. Force synchronous layout is one of the culprit that cause longer frame. Forced synchronous
layout occurs when the browser runs layout inside a script, and then does something that
forces it to recalculate styles, thus requiring it to run layout again.
5. We should know which properties trigger which step. Ref: http://csstriggers.com/
Force Synchronous Layout
for(i=0;i<divs.length;i++) {
divs[i].width = p.width;
}
1. For DOM manipulation, read property first, then write.
2. Use requestAnimationFrame instead of setInterval or setTimeout when possible
3. Find alternative for animation instead of modifying DOM inside script
Solution
Following code forces to do layout again and again in every loop.
var pWidth = p.width;
for(i=0;i<divs.length;i++) {
divs[i].width = pWidth;
}
Following code is better than previous one because it saves forcing layout when width of P reads.
Why do frame missed?
Browser gives our work higher priority. We must hand over control to main thread as soon
as possible.
setTimeout/setInterval or long running script prohibits for completing frame on time
Poor optimization CSS (not browser friendly) takes time to complete style step in pixel
timeline. Good approach to follow BEM model. https://en.bem.info/
Idle
1. We have to maximize browser idle time but we often need idle time for preloading data or
processing other task.
2. We should handover control to main thread by 50ms
Tradeoff
There is always a tradeoff
Rich UI vs Paint Time
Composite layer vs Memory & CPU
Browser friendly CSS vs Load time
and so on...
Our Goal or TO DO
1. Keeping minimum frame rate 15/sec
2. Keeping average frame rate 55/sec
3. Using web worker to reduce pressure from main thread
4. Using of requestAnimationFrame instead of setInterval and setTimeout when possible
5. Optimized stylesheet or making brower friendly
6. Migrate some element to new composite layer

More Related Content

What's hot

Leeward WordPress Meetup- Caching and Website Speed
Leeward WordPress Meetup- Caching and Website SpeedLeeward WordPress Meetup- Caching and Website Speed
Leeward WordPress Meetup- Caching and Website SpeedArlen Nagata
 
Performace optimizations and frontend happiness
Performace optimizations and frontend happinessPerformace optimizations and frontend happiness
Performace optimizations and frontend happinessnuria_ruiz
 
Overview: How to Measure your WebApp
Overview: How to Measure your WebAppOverview: How to Measure your WebApp
Overview: How to Measure your WebAppChang W. Doh
 
1 training intro
1 training intro1 training intro
1 training introSayed Ahmed
 
More efficient, usable web
More efficient, usable webMore efficient, usable web
More efficient, usable webChris Mills
 
Week 1 - How the Web Woks + Wordpress 101
Week 1 - How the Web Woks + Wordpress 101Week 1 - How the Web Woks + Wordpress 101
Week 1 - How the Web Woks + Wordpress 101Drake Martinet
 
Async ... Await – concurrency in java script
Async ... Await – concurrency in java scriptAsync ... Await – concurrency in java script
Async ... Await – concurrency in java scriptAthman Gude
 
04 09-2018--ssh blue-to_red
04 09-2018--ssh blue-to_red04 09-2018--ssh blue-to_red
04 09-2018--ssh blue-to_redAlexander Bitar
 
Web site loading time optimization
Web site loading time optimizationWeb site loading time optimization
Web site loading time optimizationDamith Kothalawala
 
Week 1 Slides - Cosmology of the Modern WordPress Web
Week 1 Slides - Cosmology of the Modern WordPress WebWeek 1 Slides - Cosmology of the Modern WordPress Web
Week 1 Slides - Cosmology of the Modern WordPress WebDrake Martinet
 
Oh CSS! - 5 Quick Things
Oh CSS! - 5 Quick ThingsOh CSS! - 5 Quick Things
Oh CSS! - 5 Quick ThingsVishu Singh
 
WordCamp RVA 2011 - Performance & Tuning
WordCamp RVA 2011 - Performance & TuningWordCamp RVA 2011 - Performance & Tuning
WordCamp RVA 2011 - Performance & TuningTimothy Wood
 
WebAssembly - kolejny buzzword, czy (r)ewolucja?
WebAssembly - kolejny buzzword, czy (r)ewolucja?WebAssembly - kolejny buzzword, czy (r)ewolucja?
WebAssembly - kolejny buzzword, czy (r)ewolucja?Brainhub
 
Journey To The Front End World - Part3 - The Machine
Journey To The Front End World - Part3 - The MachineJourney To The Front End World - Part3 - The Machine
Journey To The Front End World - Part3 - The MachineIrfan Maulana
 
Wp frameworks- WordCamp KTM #10
Wp frameworks- WordCamp KTM #10Wp frameworks- WordCamp KTM #10
Wp frameworks- WordCamp KTM #10Suman Maharjan
 
Talk Nerdy to Me: Optimizing big websites
Talk Nerdy to Me: Optimizing big websitesTalk Nerdy to Me: Optimizing big websites
Talk Nerdy to Me: Optimizing big websitesAndreas - Creten
 

What's hot (18)

Leeward WordPress Meetup- Caching and Website Speed
Leeward WordPress Meetup- Caching and Website SpeedLeeward WordPress Meetup- Caching and Website Speed
Leeward WordPress Meetup- Caching and Website Speed
 
WebAssembly Overview
WebAssembly OverviewWebAssembly Overview
WebAssembly Overview
 
Web Assembly (W3C TPAC presentation)
Web Assembly (W3C TPAC presentation)Web Assembly (W3C TPAC presentation)
Web Assembly (W3C TPAC presentation)
 
Performace optimizations and frontend happiness
Performace optimizations and frontend happinessPerformace optimizations and frontend happiness
Performace optimizations and frontend happiness
 
Overview: How to Measure your WebApp
Overview: How to Measure your WebAppOverview: How to Measure your WebApp
Overview: How to Measure your WebApp
 
1 training intro
1 training intro1 training intro
1 training intro
 
More efficient, usable web
More efficient, usable webMore efficient, usable web
More efficient, usable web
 
Week 1 - How the Web Woks + Wordpress 101
Week 1 - How the Web Woks + Wordpress 101Week 1 - How the Web Woks + Wordpress 101
Week 1 - How the Web Woks + Wordpress 101
 
Async ... Await – concurrency in java script
Async ... Await – concurrency in java scriptAsync ... Await – concurrency in java script
Async ... Await – concurrency in java script
 
04 09-2018--ssh blue-to_red
04 09-2018--ssh blue-to_red04 09-2018--ssh blue-to_red
04 09-2018--ssh blue-to_red
 
Web site loading time optimization
Web site loading time optimizationWeb site loading time optimization
Web site loading time optimization
 
Week 1 Slides - Cosmology of the Modern WordPress Web
Week 1 Slides - Cosmology of the Modern WordPress WebWeek 1 Slides - Cosmology of the Modern WordPress Web
Week 1 Slides - Cosmology of the Modern WordPress Web
 
Oh CSS! - 5 Quick Things
Oh CSS! - 5 Quick ThingsOh CSS! - 5 Quick Things
Oh CSS! - 5 Quick Things
 
WordCamp RVA 2011 - Performance & Tuning
WordCamp RVA 2011 - Performance & TuningWordCamp RVA 2011 - Performance & Tuning
WordCamp RVA 2011 - Performance & Tuning
 
WebAssembly - kolejny buzzword, czy (r)ewolucja?
WebAssembly - kolejny buzzword, czy (r)ewolucja?WebAssembly - kolejny buzzword, czy (r)ewolucja?
WebAssembly - kolejny buzzword, czy (r)ewolucja?
 
Journey To The Front End World - Part3 - The Machine
Journey To The Front End World - Part3 - The MachineJourney To The Front End World - Part3 - The Machine
Journey To The Front End World - Part3 - The Machine
 
Wp frameworks- WordCamp KTM #10
Wp frameworks- WordCamp KTM #10Wp frameworks- WordCamp KTM #10
Wp frameworks- WordCamp KTM #10
 
Talk Nerdy to Me: Optimizing big websites
Talk Nerdy to Me: Optimizing big websitesTalk Nerdy to Me: Optimizing big websites
Talk Nerdy to Me: Optimizing big websites
 

Viewers also liked

Effectively Monitoring Client-Side Performance
Effectively Monitoring Client-Side PerformanceEffectively Monitoring Client-Side Performance
Effectively Monitoring Client-Side PerformanceAndrew Rota
 
ΒιογραφικόΔΙΟΝΎΣΗΣ
ΒιογραφικόΔΙΟΝΎΣΗΣΒιογραφικόΔΙΟΝΎΣΗΣ
ΒιογραφικόΔΙΟΝΎΣΗΣdionissis milidakis
 
Unit name: Feelings.
Unit name: Feelings.Unit name: Feelings.
Unit name: Feelings.İrem Topal
 
LADIES FANCY KAFTAN MAXI DRESS
LADIES FANCY KAFTAN MAXI DRESSLADIES FANCY KAFTAN MAXI DRESS
LADIES FANCY KAFTAN MAXI DRESSLavanya's Trendzs
 
2017-1-Level-B-Bladerepair-English
2017-1-Level-B-Bladerepair-English2017-1-Level-B-Bladerepair-English
2017-1-Level-B-Bladerepair-EnglishLeif Thorup
 

Viewers also liked (10)

Effectively Monitoring Client-Side Performance
Effectively Monitoring Client-Side PerformanceEffectively Monitoring Client-Side Performance
Effectively Monitoring Client-Side Performance
 
Tecnica de la pregunta
Tecnica de la preguntaTecnica de la pregunta
Tecnica de la pregunta
 
Resume e.bakradze
Resume e.bakradzeResume e.bakradze
Resume e.bakradze
 
Window displays
Window displaysWindow displays
Window displays
 
Cikloma smart start
Cikloma smart startCikloma smart start
Cikloma smart start
 
ΒιογραφικόΔΙΟΝΎΣΗΣ
ΒιογραφικόΔΙΟΝΎΣΗΣΒιογραφικόΔΙΟΝΎΣΗΣ
ΒιογραφικόΔΙΟΝΎΣΗΣ
 
2016 Winter Saratogan
2016 Winter Saratogan2016 Winter Saratogan
2016 Winter Saratogan
 
Unit name: Feelings.
Unit name: Feelings.Unit name: Feelings.
Unit name: Feelings.
 
LADIES FANCY KAFTAN MAXI DRESS
LADIES FANCY KAFTAN MAXI DRESSLADIES FANCY KAFTAN MAXI DRESS
LADIES FANCY KAFTAN MAXI DRESS
 
2017-1-Level-B-Bladerepair-English
2017-1-Level-B-Bladerepair-English2017-1-Level-B-Bladerepair-English
2017-1-Level-B-Bladerepair-English
 

Similar to Optimizing Web Performance Through Understanding the Critical Rendering Path

Building high performing web pages
Building high performing web pagesBuilding high performing web pages
Building high performing web pagesNilesh Bafna
 
How web works and browser works ? (behind the scenes)
How web works and browser works ? (behind the scenes)How web works and browser works ? (behind the scenes)
How web works and browser works ? (behind the scenes)Vibhor Grover
 
Frontend Performance: Illusions & browser rendering
Frontend Performance: Illusions & browser renderingFrontend Performance: Illusions & browser rendering
Frontend Performance: Illusions & browser renderingManuel Garcia
 
Html from request to rendering
Html from request to renderingHtml from request to rendering
Html from request to renderingToan Nguyen
 
Netflix Webkit-Based UI for TV Devices
Netflix Webkit-Based UI for TV DevicesNetflix Webkit-Based UI for TV Devices
Netflix Webkit-Based UI for TV DevicesMatt McCarthy
 
implement lighthouse-ci with your web development workflow
implement lighthouse-ci with your web development workflowimplement lighthouse-ci with your web development workflow
implement lighthouse-ci with your web development workflowWordPress
 
Debugging perf with devtools
Debugging perf with devtoolsDebugging perf with devtools
Debugging perf with devtoolsPriyanka Kore
 
Performace optimization (increase website speed)
Performace optimization (increase website speed)Performace optimization (increase website speed)
Performace optimization (increase website speed)clickramanm
 
IBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxIBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxKarl-Henry Martinsson
 
Web browser - How web browsers work?
Web browser - How web browsers work?Web browser - How web browsers work?
Web browser - How web browsers work?Arun Kumar
 
Navigating the critical rendering path - Jamie Alberico - VirtuaCon
Navigating the critical rendering path -  Jamie Alberico - VirtuaConNavigating the critical rendering path -  Jamie Alberico - VirtuaCon
Navigating the critical rendering path - Jamie Alberico - VirtuaConJamie Indigo
 
Exploring Critical Rendering Path
Exploring Critical Rendering PathExploring Critical Rendering Path
Exploring Critical Rendering PathRaphael Amorim
 
How to write an application and not roll down to 1 fps
How to write an application and not roll down to 1 fpsHow to write an application and not roll down to 1 fps
How to write an application and not roll down to 1 fpsIntexSoft
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceArjan
 
Frontend performance
Frontend performanceFrontend performance
Frontend performancesacred 8
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application developmentzonathen
 

Similar to Optimizing Web Performance Through Understanding the Critical Rendering Path (20)

Building high performing web pages
Building high performing web pagesBuilding high performing web pages
Building high performing web pages
 
How web works and browser works ? (behind the scenes)
How web works and browser works ? (behind the scenes)How web works and browser works ? (behind the scenes)
How web works and browser works ? (behind the scenes)
 
Frontend Performance: Illusions & browser rendering
Frontend Performance: Illusions & browser renderingFrontend Performance: Illusions & browser rendering
Frontend Performance: Illusions & browser rendering
 
Html from request to rendering
Html from request to renderingHtml from request to rendering
Html from request to rendering
 
Web performance
Web performanceWeb performance
Web performance
 
Netflix Webkit-Based UI for TV Devices
Netflix Webkit-Based UI for TV DevicesNetflix Webkit-Based UI for TV Devices
Netflix Webkit-Based UI for TV Devices
 
Presentation Tier optimizations
Presentation Tier optimizationsPresentation Tier optimizations
Presentation Tier optimizations
 
implement lighthouse-ci with your web development workflow
implement lighthouse-ci with your web development workflowimplement lighthouse-ci with your web development workflow
implement lighthouse-ci with your web development workflow
 
Debugging perf with devtools
Debugging perf with devtoolsDebugging perf with devtools
Debugging perf with devtools
 
Performace optimization (increase website speed)
Performace optimization (increase website speed)Performace optimization (increase website speed)
Performace optimization (increase website speed)
 
AD102 - Break out of the Box
AD102 - Break out of the BoxAD102 - Break out of the Box
AD102 - Break out of the Box
 
IBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxIBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the Box
 
Web browser - How web browsers work?
Web browser - How web browsers work?Web browser - How web browsers work?
Web browser - How web browsers work?
 
Navigating the critical rendering path - Jamie Alberico - VirtuaCon
Navigating the critical rendering path -  Jamie Alberico - VirtuaConNavigating the critical rendering path -  Jamie Alberico - VirtuaCon
Navigating the critical rendering path - Jamie Alberico - VirtuaCon
 
Exploring Critical Rendering Path
Exploring Critical Rendering PathExploring Critical Rendering Path
Exploring Critical Rendering Path
 
How to write an application and not roll down to 1 fps
How to write an application and not roll down to 1 fpsHow to write an application and not roll down to 1 fps
How to write an application and not roll down to 1 fps
 
Making it fast: Zotonic & Performance
Making it fast: Zotonic & PerformanceMaking it fast: Zotonic & Performance
Making it fast: Zotonic & Performance
 
Frontend performance
Frontend performanceFrontend performance
Frontend performance
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
 
Speed!
Speed!Speed!
Speed!
 

Recently uploaded

MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 

Recently uploaded (20)

MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 

Optimizing Web Performance Through Understanding the Critical Rendering Path

  • 2. Goal of the discussion Sharing knowledge of web performance Determination of our Goal
  • 3. What is web performance really mean? Performance is the art of avoiding work. Really?? Yep, only if no one complains against that performance. ACTION Expected Time (ms) Load Under 1000ms Response Under 100ms Animation Under 16ms Idle Maximize. Script chunked should not be larger than 50ms Expected Performance
  • 4. LOAD 1. Critical content should be loaded under 1000ms 2. Showing an update (e.g showing a loader) if it takes more than 1000ms 3. It includes network latency time What is critical content? Let's go through how browser process response from webserver 1. Document Object Model (DOM) 2. CSS Object Model (CSSOM)
  • 5. Bytes Browser receives bytes from server Characters Convert bytes to character based on specified encoding Tokens Tokenize characters to tokens <html>, </html>, <head>, </head> Nodes Tokens are converted to node e.g head, body, div DOM Constructs THE DOM DOM
  • 6. Bytes Browser receives bytes from server Characters Convert bytes to character based on specified encoding Tokens Tokenize characters to tokens <html>, </html>, <head>, </head> Nodes Tokens are converted to node e.g head, body, div CSSOM Constructs THE CSSOM CSSOM
  • 9. DOM vs CSSOM 1. DOM and CSSOM are independent data structures. 2. Chrome DevTools Timeline allows us to capture and inspect the construction and processing costs of DOM and CSSOM. 3. DOM and CSSOM construct RENDER TREE together
  • 10. Render Tree 1. The DOM and CSSOM trees are combined to form the render tree. 2. Render tree contains only the nodes required to render the page. For example, node with css display:none does not include inside render tree
  • 11. Layout and Paint 1. Layout computes the exact position and size of each object. 2. Finally comes to Paint step that takes in the final render tree and renders the pixels to the screen. 1. Process HTML markup and build the DOM tree. 2. Process CSS markup and build the CSSOM tree. 3. Combine the DOM and CSSOM into a render tree. 4. Run layout on the render tree to compute geometry (width, height, position etc) of each node. 5. Paint the individual nodes to the screen. Feel the browser pain again :( This full process is called critical rendering path
  • 12. Rendering blocks 1. HTML file 2. CSS file unless explicitly used media type. e.g. media=”print” does not block in case of browser view 3. Javascript file unless explicitly declared as async. Because Javascript can modify DOM and CSSOM 4. In a words, browser stop rendering until final DOM and CSSOM is completed Noted that images are not rending block resource Browser events domContentLoaded - Fire when render tree is ready domComplete - Fire when all resources including images are loading completed
  • 13. Finally “Load” comes to end Let's define the vocabulary we’ll be using to describe the critical rendering path: Critical Resource: resource that may block initial rendering of the page. Example, html, js, css file Critical Path Length: number of network roundtrips, or the total time required to fetch all of the critical resources. Critical Bytes: total amount of bytes required to get to first render of the page All should be completed under 1000ms
  • 14. Optimization of “Load” Step 1. Good server-end 2. Prefer async JavaScript resources 3. Avoid synchronous server calls e.g sync ajax request 4. Avoid long running JavaScript 5. Put CSS in the document head 6. Avoid CSS imports
  • 15. Response 1. Should be under 100ms with input latency 2. Should be under 16ms without input latency
  • 16. Animation Each frame should be ready under 16ms Why? 1. Because most of the device refresh rate is 60 frames/Sec i.e 60 FPS 2. Human eye does not differentiate frame change in this rate 3. 60 frames/Sec, so each frame = 1000ms/60 = ~16.5ms 4. Browser have to ready each frame by 16ms 5. Normally we get 10ms for each frame because browser has some housekeeping to make ready the frame before sending to display device
  • 17. JavaScript Style Layout Paint Composite The pixel Pipeline 1. Browser have to follow each step for each frame depending on the changes 2. Sometimes browsers need to calculate same steps several times 3. Performance depends on how less brower work to complete the pixel pipeline 4. Force synchronous layout is one of the culprit that cause longer frame. Forced synchronous layout occurs when the browser runs layout inside a script, and then does something that forces it to recalculate styles, thus requiring it to run layout again. 5. We should know which properties trigger which step. Ref: http://csstriggers.com/
  • 18. Force Synchronous Layout for(i=0;i<divs.length;i++) { divs[i].width = p.width; } 1. For DOM manipulation, read property first, then write. 2. Use requestAnimationFrame instead of setInterval or setTimeout when possible 3. Find alternative for animation instead of modifying DOM inside script Solution Following code forces to do layout again and again in every loop.
  • 19. var pWidth = p.width; for(i=0;i<divs.length;i++) { divs[i].width = pWidth; } Following code is better than previous one because it saves forcing layout when width of P reads.
  • 20. Why do frame missed? Browser gives our work higher priority. We must hand over control to main thread as soon as possible. setTimeout/setInterval or long running script prohibits for completing frame on time Poor optimization CSS (not browser friendly) takes time to complete style step in pixel timeline. Good approach to follow BEM model. https://en.bem.info/
  • 21. Idle 1. We have to maximize browser idle time but we often need idle time for preloading data or processing other task. 2. We should handover control to main thread by 50ms Tradeoff There is always a tradeoff Rich UI vs Paint Time Composite layer vs Memory & CPU Browser friendly CSS vs Load time and so on...
  • 22. Our Goal or TO DO 1. Keeping minimum frame rate 15/sec 2. Keeping average frame rate 55/sec 3. Using web worker to reduce pressure from main thread 4. Using of requestAnimationFrame instead of setInterval and setTimeout when possible 5. Optimized stylesheet or making brower friendly 6. Migrate some element to new composite layer