Web Performance *IS* User Experience
image: Browser
The time it takes to get all the resources from all the servers
image: fil
The longest delay is the time it takes to make the round trip time between the phone and the cell tower. Air is the greatest cause of latency
Mobile browsers are super powerful. Mobile devices are not
image: server
image: browser with duck-duck-go loaded
image: web page with duck-duck-go search results
image: browser with a white screen
<!doctype HTML> <html lang="en-us"> <head> <meta charset="UTF-8"/> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>My site</title> <link rel="stylesheet" src="styles.css"/> <script src="myscript.js"></script> </head> <body> <h1>My Page</h1> <p>A paragraph with an <a href="//example.com">link</a></p> <figure> <img src="myImage.jpg" alt="description of the image"/> <caption>My photo</caption> </figure> <script src="anotherscript.js"></script> </body> </html>
It's not that simple...
Populating the page
User Interaction
image: search results from duck-duck-go
image: browser with no content (a white screen)
It's not that simple...
DNS = Domain Name System
www.example.com
93.184.216.34
Steps
TCP three-way handshake
TLS Negotiation
Transmission Control Protocol
Transport Layer Security (TLS) protocol
Establish a connection
The host, usually the browser, sends a TCP SYNchronize packet to the server. The server receives the SYN and sends back a SYNchronize ACKnowledgment. The host receives the SYN-ACK from the server and sends an ACKnowledgment. The server receives ACK and the TCP socket connection is established.
Determines the encryption for communication
It's not that simple...
Algorithm to detect available bandwidth
Confirm delivery by returning ACK, acknowledgments of receipt
Confirm delivery by returning ACK, acknowledgments of receipt
<!doctype HTML> <html lang="en-us"> <head> <meta charset="UTF-8"/> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>My site</title> <link rel="stylesheet" src="styles.css"/> <script src="myscript.js"></script> </head> <body> <h1>My Page</h1> <p>A paragraph with an <a href="//example.com">link</a></p> <figure> <img src="myImage.jpg" alt="image description"/> <caption>My photo</caption> </figure> <script src="anotherscript.js"></script> </body> </html>
It's not that simple
Document Object Model,
describes the content
Requests high priority resources
<link rel="stylesheet" src="styles.css"/> <script src="myscript.js" async></script> <img src="myImage.jpg" alt="image description"/> <script src="unautrescript.js" defer></script>
<script> | RENDER | PAUSE | RENDER | ||
DOWNLOAD | |||||
EXECUTE | |||||
<script defer> | RENDER | ||||
DOWNLOAD | |||||
EXECUTE | |||||
<script async> | RENDER | PAUSE | RENDER | ||
DOWNLOAD | |||||
EXECUTE |
<!doctype HTML>
<html lang="en-us">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My site</title>
<link rel="stylesheet" src="styles.css"/>
<script src="myscript.js"></script>
</head>
<body>
<h1>My Page</h1>
<p>A paragraph with <a href="//example.com">link</a></p>
<figure>
<img src="myImage.jpg" alt="image description"/>
<caption>My photo</caption>
</figure>
<script src="anotherscript.js"></script>
</body>
</html>
Describes the style rules
:root { font-size: 16px; } body { color: #333333; } h1 { font-size: 2rem; } p a { color: blue; } figure img { border: none; width: 100%; }
:root { font-size: 16px; } body { color: #333333; } h1 { font-size: 2rem; } p a { color: blue; } figure img { border: none; width: 100%; }
:root { font-size: 16px; } body { color: #333333; } h1 { font-size: 2rem; } p a { color: blue; } img { border: none; width: 100%; }
image: screen shot of accessiblity tab showing accessiblity names
Until the construction of the AOM, the content is not accessible to screen readers.
*Analyzed in abstract syntax trees, generating optimize and / or binary code executed on the main thread .
**Will generate an error if JavaScript is executed on a DOM node that has not yet been encountered
Screen shot of a simple javascript event handler in ASTExplorer.net
DOM and CSSOM: combined to form the rendering tree. Contains only the nodes necessary to render the page.
Creation of the "Render Tree" - Computed Styles
visibility: hidden
: yesdisplay: none
: noDetermines the CSS rules for each visible (and hidden) node.
Calculate the layout of each visible element
Determine the dimensions of all nodes in the render tree
img { width: 100%; }
<img src="myImage.jpg" alt="image description "/>
img { width: 100%; height: auto; }
<img src="myImage.jpg" alt="image description " width="100" height="100"/>
z-index
<video>
and <canvas>
will-change
property isolation: isolate
Merge the layers to calculate the
RGBA value of each pixel
When a change is made:
Recalculate almost everything!
img { width: 100%; }
<img src="myImage.jpg" alt="image description "/>
img { width: 100%; height: auto; }
<img src="myImage.jpg" alt="image description " width="100" height="100"/>
No blocking on the main thread. Should respond to the user in less than 50ms and animate in less than 16.67ms (60fps)