2. Main Browser Components
User Interface
Browser Engine
Rendering Engine
Networking
JavaScript
Interpreter
XML Parser
Display
Backend
DataStorage
Source: “A Reference Architecture for Web Browsers” by Alan Grosskurth and Michael Godfrey
3. Main Browser Components
User Interface
Browser Engine
Rendering Engine
Networking
JavaScript
Interpreter
XML Parser
Display
Backend
DataStorage
Source: “A Reference Architecture for Web Browsers” by Alan Grosskurth and Michael Godfrey
12. HTML Parser: Tokens
Characters Tokens Nodes DOMBytes
StartTag: <html> EndTag: </html>
Text
AttributeName:
class
AttributeValue:
“outer”
13. Tokenisation: Output
StartTag: html StartTag: head
EndTag: head
StartTag: body
EndTag: htmlEndTag: body
StartTag: h1
DOM Example
EndTag: h1
…
StartTag: meta StartTag: link
StartTag: title EndTag: title
DOM Example
StartTag: p EndTag: pStartTag: span EndTag: span… …
StartTag: img
AttributeName:
src
AttributeValue:
example.jpg
14. HTML Parser: Syntax Analysis
Characters Tokens Nodes DOMBytes
html head
body
meta link title
h1 p img
Lorem ipsum
dolor sit amet,
span
DOM Example
elit, sed do eiusmod
tempor incididunt ut
labore et dolore magna
aligua.
consectetur
adipiscing
15. HTML Parser: DOM
Characters Tokens Nodes DOMBytes
html
head body
meta link title h1 p img
DOM Example
span
elit, sed do
…
consectetur
adipiscing
Lorem ipsum
dolor sit amet,
19. CSS Style Objects
CSSStyleSheet
CSSRule CSSRuleCSSRule
Selector Declaration Selector Declaration Selector Declaration
body h1 p
font-sizefont-size 12px 16px color red
20. CSS Object Model
body
h1 p img
span
font-size: 12px
font-size: 12px
font-size: 16px
font-size: 12px
float: right
font-size: 12px
color: red
font-size: 12px
color: red
color: blue
display: none
23. Render tree construction: DOM
html
head body
meta link title h1 p img
DOM Example
span
elit, sed do
…
consectetur
adipiscing
Lorem ipsum
dolor sit amet,
24. Render tree construction: DOM
html
head body
meta link title h1 p img
DOM Example
span
elit, sed do
…
consectetur
adipiscing
Lorem ipsum
dolor sit amet,
25. Render tree construction:
style computation
body
h1 p img
DOM Example
elit, sed do
…
Lorem ipsum
dolor sit amet,
font-size: 12px
font-size: 16px
font-size: 12px
color: red
font-size: 12px
float: right
29. Positioning
• Normal flow
• box formatting context (block and inline)
• relative positioning
• Floats
• first: lay out box according to normal flow
• then: push as far left/right as possible
• Absolute and fixed positioning
• box is taken out of normal flow
• positioned dependent on the box’s containing
block (absolute) or the viewport (fixed)
30. Layout process
• global vs. incremental layout
• dirty bit system
• placement, width & height calculation
39. Optimization
• Optimize time to first render by minimizing[1]
• number of critical resources
• critical path length
• number of critical bytes
40. References and further reading
[1] Google Web Fundamentals: Critical Rendering Path by Ilya Grigorik
[2] Google Web Fundamentals: Rendering Performance by Paul Lewis
[2] How browsers work: Behind the scenes of modern web browsers by Tali Garsiel
[3] W3C: HTML 5 - A vocabulary and associated APIs for HTML and XHTML
[4] W3C: Cascading Style Sheet Level 2 Revision 1 (CSS 2.1) Specification
[5] W3C: DOM4
[5] A Reference Architecture for Web Browsers by Alan Grosskurth and Michael W. Godfrey
[6] Understanding the critical rendering path, rendering pages in 1 second by Luis Vieira
[7] Usability Engineering by Jakob Nielsen
[8] Response Times: The 3 Important Limits by Jakob Nielsen
[9] Optimising the Critical Rendering Path by Stephan Max
[10] CSS Mastery - Advanced Web Standard Solutions by Andy Budd