SlideShare a Scribd company logo
L E T S S E E W H A T S B E H I N D T H E
S C E N E S
PROGRAMMING | JAVASCRIPT
Follow on Instagram
js.helpful
Follow on dev.to
vibhorme
Users want web experiences with content that is fast to load and smooth to interact with.
Therefore, a developer should strive to achieve these two goals
Overview
latency
browsers are single threaded
Two major issues in web performance having to do with
1.
2.
Web performance is what we have to do to make the page load
happen as quickly as possible
Follow on Instagram
js.helpful
Latency is our main threat to overcome to ensure a
fast load. To be fast to load, the developers’ goals
include sending requested information as fast as
possible
Whats Latency ?
**Network latency is the time it takes to transmit bytes over-the-
air to computers
Follow on Instagram
js.helpful
most browsers are single threaded
cross platform browsers responds differently
1.
2.
Browser Issues
For smooth interactions, the our goal is to ensure performant site
interactions, from smooth scrolling to being responsive to touch
Follow on Instagram
js.helpful
Web performance can be improved by understanding
the single-threaded nature of the browser
minimising the main thread's responsibilities, where possible and
appropriate, to ensure rendering is smooth and responses to interactions
are immediate
Follow on Instagram
js.helpful
Lets Understand How the Browser Works and how we can
optimise our applications
Follow on Instagram
js.helpful
If you navigate to https://example.com, the HTML page is located on the server with IP address
of 93.184.216.34. If you’ve never visited this site, a DNS lookup must happen
Lets understand what happens when you enter a URL in the browser
The first step of navigating
to a web page is finding
where the assets for that
page are located.
If your fonts, images, scripts, ads, and metrics all have different hostnames, a
DNS lookup will have to be made for each one (Performance concern)
TCP Handshake (how the browser communicates with the server)
Once the IP address is known, the browser sets up a connection to the server via a TCP three-way
handshake
For secure connections established over
HTTPS, another "handshake" is required.
This handshake, or rather the TLS
negotiation, creates a secures the
connection
**While making the connection secure adds
time to the page load, a secure connection is
worth the latency expense, as the data
transmitted between the browser and the web
server cannot be decrypted by a third party
(performance concern)
Response
Once we have an established connection to a web server, the browser
sends an initial HTTP GET request on behalf of the user
Once the server receives the
request, it will reply with relevant
response headers and the
contents of the HTML.
Follow on Instagram
js.helpful
The first response packet will be 14Kb. This
is part of TCP slow start, an algorithm
which balances the speed of a network
connection. Slow start gradually increases
the amount of data transmitted until the
network's maximum bandwidth can be
determined
Response
Time to First Byte (TTFB) is the time between when the user made the request—say by clicking on a link—and
the receipt of this first packet of HTML. The first chunk of content is usually 14kb of data
If you’ve ever heard of the 14Kb rule for initial
page load, TCP slow start is the reason why the
initial response is 14Kb, and why web
performance optimization calls for focusing
optimizations with this initial 14Kb response in
mind
But before anything is rendered to the screen, the HTML, CSS, and JavaScript have to be parsed
Parsing the Response
Parsing is the step the browser takes to turn the data it receives over the network into the DOM
and CSSOM, which is used by the renderer to paint a page to the screen
How Javscript is parsed by the
browser ?
Follow on Instagram
js.helpful
Building the DOM tree
The first step is processing the HTML markup and building the DOM tree
The parser parses tokenized input into the document, building up the document tree
When the parser finds non-blocking resources, such as an image, the browser will request those
resources and continue parsing. Parsing can continue when a CSS file is encountered,
but
<script> tags—particularly those without an async or defer attribute—block rendering, and
pause the parsing of HTML. (Performance concern)
While Parsing ...
Building the Accessibility Tree
Other Processes
JavaScript Compilation
The browser also builds an accessibility tree that assistive devices use to parse and
interpret content
Follow on Instagram
js.helpful
Render
Style
Layout
Paint
Compositing
Rendering steps include
The CSSOM and DOM trees created in the parsing step are combined into a render
tree which is then used to compute the layout of every visible element, which is then
painted to the screen
Follow on Instagram
js.helpful
Render
Style
Tags that aren't going to be displayed, like the <head> and its children and any nodes
with display: none, such as the script { display: none; } you will find in user agent
stylesheets, are not included in the render tree as they will not appear in the rendered
output. Nodes with visibility: hidden applied are included in the render tree, as
they do take up space (Performance concern)
Follow on Instagram
js.helpful
Render
Layout is the process by which the width, height, and location of all the nodes in the render
tree are determined, plus the determination of the size and position of each object on the page
Layout and Reflow
On the web page, most everything is a box
In this phase, taking the viewport size into consideration, the browser
determines what the dimensions of all the different boxes are going to be on
the screen.
for example, we have a image in a webpage, while rendering, suppose the initial layout occurs before the image is
returned. Since we didn't declare the size of our image, there will be a reflow once the image size is known.
(Performance concern as reflow causes rerendering)
whereas, Reflow is any subsequent size and position determination of any part of the page
or the entire document.
Render
painting the individual nodes to the screen, the first occurence of which is called the first meaningful paint
Paint
In the painting or rasterization phase, the browser converts each box calculated in the layout
phase to actual pixels on the screen
Painting can break the elements in the layout tree into layers. Promoting content
into layers on the GPU (instead of the main thread on the CPU) improves paint and
repaint performance. There are specific properties and elements that instantiate
a layer, including <video> and <canvas>, and any element which has the CSS
properties of opacity, a 3D transform, will-change, and a few others (performance
concern)
Render
sections of the document are drawn in different layers, overlapping each other, compositing is necessary to
ensure they are drawn to the screen in the right order and the content is rendered correctly
Compositing
As the page continues to load assets, reflows can happen (recall our example image
that arrived late). A reflow sparks a repaint and a re-composite. Had we defined the
size of our image, no reflow would have been necessary, and only the layer that needed to
be repainted would be repainted, and composited if necessary
Follow on Instagram
js.helpful
If we take care of the base elements and the structuring of
our applications, webpages. It can really help us in creating
optimised solutions
Conclusion
Thank you
VIBHOR GROVER
Follow on Instagram
js.helpful
Follow on dev.to
vibhorme

More Related Content

PPT
Graphql presentation
PDF
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
PDF
Graphql
PDF
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
PDF
Better APIs with GraphQL
PDF
GraphQL London January 2018: Graphql tooling
PPTX
An intro to GraphQL
PPTX
GraphQL Introduction
Graphql presentation
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
Graphql
Introduction to GraphQL (or How I Learned to Stop Worrying about REST APIs)
Better APIs with GraphQL
GraphQL London January 2018: Graphql tooling
An intro to GraphQL
GraphQL Introduction

What's hot (17)

PDF
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
PDF
GraphQL across the stack: How everything fits together
PDF
The Apollo and GraphQL Stack
PPTX
Introduction to GraphQL
PDF
GraphQL + relay
PDF
GraphQL in an Age of REST
PDF
GraphQL: Enabling a new generation of API developer tools
PPTX
Introduction to GraphQL
PDF
Performance optimisation with GraphQL
PDF
GraphQL over REST at Reactathon 2018
PDF
Intro to GraphQL
PDF
REST vs GraphQL
PDF
GraphQL
PDF
Adding GraphQL to your existing architecture
PDF
GraphQL - A query language to empower your API consumers (NDC Sydney 2017)
PDF
Introduction to GraphQL at API days
PDF
GraphQL & Relay
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
GraphQL across the stack: How everything fits together
The Apollo and GraphQL Stack
Introduction to GraphQL
GraphQL + relay
GraphQL in an Age of REST
GraphQL: Enabling a new generation of API developer tools
Introduction to GraphQL
Performance optimisation with GraphQL
GraphQL over REST at Reactathon 2018
Intro to GraphQL
REST vs GraphQL
GraphQL
Adding GraphQL to your existing architecture
GraphQL - A query language to empower your API consumers (NDC Sydney 2017)
Introduction to GraphQL at API days
GraphQL & Relay
Ad

Similar to How web works and browser works ? (behind the scenes) (20)

PPTX
Optimizing Browser Rendering
PPTX
Web performance
PPTX
Web performance
PDF
Frontend Performance: Illusions & browser rendering
PDF
Exploring Critical Rendering Path
PPTX
Browsers. Magic is inside.
PPT
Please dont touch-3.6-jsday
PDF
Performance on the Yahoo! Homepage
PDF
Understanding Page Load / Ziling Zhao (Google)
PDF
Building performance into the new yahoo homepage presentation
PDF
The Mobile Web - HTML5 on mobile devices
PDF
PrairieDevCon 2014 - Web Doesn't Mean Slow
PDF
Performance (browser)
PPTX
Web browser - How web browsers work?
PDF
Using React for the Mobile Web
PDF
OutSystems Webinar - Troubleshooting Mobile Apps Performance
PDF
Training Webinar: Troubleshooting Mobile Apps Performance
PPTX
Vlad zelinschi optimizing the critical rendering path
PDF
#Webperf Choreography
DOCX
How Browsers Work -By Tali Garsiel and Paul Irish
Optimizing Browser Rendering
Web performance
Web performance
Frontend Performance: Illusions & browser rendering
Exploring Critical Rendering Path
Browsers. Magic is inside.
Please dont touch-3.6-jsday
Performance on the Yahoo! Homepage
Understanding Page Load / Ziling Zhao (Google)
Building performance into the new yahoo homepage presentation
The Mobile Web - HTML5 on mobile devices
PrairieDevCon 2014 - Web Doesn't Mean Slow
Performance (browser)
Web browser - How web browsers work?
Using React for the Mobile Web
OutSystems Webinar - Troubleshooting Mobile Apps Performance
Training Webinar: Troubleshooting Mobile Apps Performance
Vlad zelinschi optimizing the critical rendering path
#Webperf Choreography
How Browsers Work -By Tali Garsiel and Paul Irish
Ad

Recently uploaded (20)

PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
Sustainable Sites - Green Building Construction
PDF
Well-logging-methods_new................
DOCX
573137875-Attendance-Management-System-original
PPTX
additive manufacturing of ss316l using mig welding
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Geodesy 1.pptx...............................................
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPT
Mechanical Engineering MATERIALS Selection
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Sustainable Sites - Green Building Construction
Well-logging-methods_new................
573137875-Attendance-Management-System-original
additive manufacturing of ss316l using mig welding
Embodied AI: Ushering in the Next Era of Intelligent Systems
Geodesy 1.pptx...............................................
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Mechanical Engineering MATERIALS Selection
UNIT 4 Total Quality Management .pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Lesson 3_Tessellation.pptx finite Mathematics
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Operating System & Kernel Study Guide-1 - converted.pdf
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...

How web works and browser works ? (behind the scenes)

  • 1. L E T S S E E W H A T S B E H I N D T H E S C E N E S PROGRAMMING | JAVASCRIPT Follow on Instagram js.helpful Follow on dev.to vibhorme
  • 2. Users want web experiences with content that is fast to load and smooth to interact with. Therefore, a developer should strive to achieve these two goals Overview latency browsers are single threaded Two major issues in web performance having to do with 1. 2. Web performance is what we have to do to make the page load happen as quickly as possible Follow on Instagram js.helpful
  • 3. Latency is our main threat to overcome to ensure a fast load. To be fast to load, the developers’ goals include sending requested information as fast as possible Whats Latency ? **Network latency is the time it takes to transmit bytes over-the- air to computers Follow on Instagram js.helpful
  • 4. most browsers are single threaded cross platform browsers responds differently 1. 2. Browser Issues For smooth interactions, the our goal is to ensure performant site interactions, from smooth scrolling to being responsive to touch Follow on Instagram js.helpful
  • 5. Web performance can be improved by understanding the single-threaded nature of the browser minimising the main thread's responsibilities, where possible and appropriate, to ensure rendering is smooth and responses to interactions are immediate Follow on Instagram js.helpful
  • 6. Lets Understand How the Browser Works and how we can optimise our applications Follow on Instagram js.helpful
  • 7. If you navigate to https://example.com, the HTML page is located on the server with IP address of 93.184.216.34. If you’ve never visited this site, a DNS lookup must happen Lets understand what happens when you enter a URL in the browser The first step of navigating to a web page is finding where the assets for that page are located. If your fonts, images, scripts, ads, and metrics all have different hostnames, a DNS lookup will have to be made for each one (Performance concern)
  • 8. TCP Handshake (how the browser communicates with the server) Once the IP address is known, the browser sets up a connection to the server via a TCP three-way handshake For secure connections established over HTTPS, another "handshake" is required. This handshake, or rather the TLS negotiation, creates a secures the connection **While making the connection secure adds time to the page load, a secure connection is worth the latency expense, as the data transmitted between the browser and the web server cannot be decrypted by a third party (performance concern)
  • 9. Response Once we have an established connection to a web server, the browser sends an initial HTTP GET request on behalf of the user Once the server receives the request, it will reply with relevant response headers and the contents of the HTML. Follow on Instagram js.helpful
  • 10. The first response packet will be 14Kb. This is part of TCP slow start, an algorithm which balances the speed of a network connection. Slow start gradually increases the amount of data transmitted until the network's maximum bandwidth can be determined Response Time to First Byte (TTFB) is the time between when the user made the request—say by clicking on a link—and the receipt of this first packet of HTML. The first chunk of content is usually 14kb of data If you’ve ever heard of the 14Kb rule for initial page load, TCP slow start is the reason why the initial response is 14Kb, and why web performance optimization calls for focusing optimizations with this initial 14Kb response in mind
  • 11. But before anything is rendered to the screen, the HTML, CSS, and JavaScript have to be parsed Parsing the Response Parsing is the step the browser takes to turn the data it receives over the network into the DOM and CSSOM, which is used by the renderer to paint a page to the screen How Javscript is parsed by the browser ? Follow on Instagram js.helpful
  • 12. Building the DOM tree The first step is processing the HTML markup and building the DOM tree The parser parses tokenized input into the document, building up the document tree When the parser finds non-blocking resources, such as an image, the browser will request those resources and continue parsing. Parsing can continue when a CSS file is encountered, but <script> tags—particularly those without an async or defer attribute—block rendering, and pause the parsing of HTML. (Performance concern) While Parsing ...
  • 13. Building the Accessibility Tree Other Processes JavaScript Compilation The browser also builds an accessibility tree that assistive devices use to parse and interpret content Follow on Instagram js.helpful
  • 14. Render Style Layout Paint Compositing Rendering steps include The CSSOM and DOM trees created in the parsing step are combined into a render tree which is then used to compute the layout of every visible element, which is then painted to the screen Follow on Instagram js.helpful
  • 15. Render Style Tags that aren't going to be displayed, like the <head> and its children and any nodes with display: none, such as the script { display: none; } you will find in user agent stylesheets, are not included in the render tree as they will not appear in the rendered output. Nodes with visibility: hidden applied are included in the render tree, as they do take up space (Performance concern) Follow on Instagram js.helpful
  • 16. Render Layout is the process by which the width, height, and location of all the nodes in the render tree are determined, plus the determination of the size and position of each object on the page Layout and Reflow On the web page, most everything is a box In this phase, taking the viewport size into consideration, the browser determines what the dimensions of all the different boxes are going to be on the screen. for example, we have a image in a webpage, while rendering, suppose the initial layout occurs before the image is returned. Since we didn't declare the size of our image, there will be a reflow once the image size is known. (Performance concern as reflow causes rerendering) whereas, Reflow is any subsequent size and position determination of any part of the page or the entire document.
  • 17. Render painting the individual nodes to the screen, the first occurence of which is called the first meaningful paint Paint In the painting or rasterization phase, the browser converts each box calculated in the layout phase to actual pixels on the screen Painting can break the elements in the layout tree into layers. Promoting content into layers on the GPU (instead of the main thread on the CPU) improves paint and repaint performance. There are specific properties and elements that instantiate a layer, including <video> and <canvas>, and any element which has the CSS properties of opacity, a 3D transform, will-change, and a few others (performance concern)
  • 18. Render sections of the document are drawn in different layers, overlapping each other, compositing is necessary to ensure they are drawn to the screen in the right order and the content is rendered correctly Compositing As the page continues to load assets, reflows can happen (recall our example image that arrived late). A reflow sparks a repaint and a re-composite. Had we defined the size of our image, no reflow would have been necessary, and only the layer that needed to be repainted would be repainted, and composited if necessary Follow on Instagram js.helpful
  • 19. If we take care of the base elements and the structuring of our applications, webpages. It can really help us in creating optimised solutions Conclusion Thank you VIBHOR GROVER Follow on Instagram js.helpful Follow on dev.to vibhorme