SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
25.
USER INTERFACE
BROWSER ENGINE
RENDERING ENGINE
NETWORKING
JavaScript
INTERPRETER
UI BACKEND
DATAPERSISTENCE
V8, SpiderMonkey
WebKit, Gecko,
Blink, Trident
WEB APIs
25
BROWSER WEB APIs
26.
WEB APIs
Web Sockets
Messaging
WebRTC
Canvas
SVG
WebGL
File API
File System API
Indexed DB
DOM
Drag and Drop
Fullscreen
Animation
Timing
Media
Pointer Lock
Web Audio
Browser
Shadow DOM
Typed Arrays
Web Workers
CSS Object Model
Selectors
BROWSER WEB APIs
27.
Event Loop / Task Queue
Philip Roberts
http://latentflip.com/loupe
Event
loop
Call stack
BROWSER WEB APIs EVENT LOOP
macro
micro
micro
micro
task queue
33.
GECKO vs WebKit
BROWSER GECKO vs WebKitRENDERING ENGINE
34.
WebKit
DOM
BROWSER HTML PARSERWebKitRENDERING ENGINE
35.
HTML Parser
Tokeniser
Lexical Analyzer
(Flex => Bison)
Tree construction
Syntax analyser
DOM
Script
Execution
document.write();
document.appendChild();
element.innerHTML
BROWSER HTML PARSERWebKitRENDERING ENGINE
36.
Tokeniser
Lexical Analyzer
(Flex => Bison)
Tree construction
Syntax analyser
<p> I <span>ma i n p
I ma i n s p a
</span> </p>
DOM
html
head body
p
span
I am in span
n
linkmeta
I am in p
div
img
<p>
I am in p
<span>
I am in span
</span>
</p>
BROWSER HTML PARSERWebKit EXAMPLERENDERING ENGINE
37.
Dealing with Resources
• Render blocking
• Parser blocking
• Non blocking
BROWSER HTML PARSERWebKit DEALING WITH RESOURCESRENDERING ENGINE
38.
No Resource
<html>
<head>
<title>Critical Path: No Style</title>
</head>
<body>
<p>Hello World</p>
</body>
</html>
BROWSER HTML PARSERWebKit DEALING WITH RESOURCES NO RESOURCESRENDERING ENGINE
46.
#main-navigation { } /* ID (Fastest) */
body.home #wrapper { } /* ID */
.main-navigation { } /* Class */
ul li a.current { } /* Class */
ul { } /* Tag */
ul li a { } /* Tag */
* { } /* Universal (Slowest) */
#content [title='home'] /* Universal */
ID selectors
main-navigation { }
wrapper { }
Class selectors
main-navigation { }
current { }
Tag selectors
ul { }
a { }
Universal selectors
* { }
[title='home'] { }
BROWSER WebKit CSS PERFORMANCE
CSS Selectors Performance
RENDERING ENGINE
47.
Chrome Firefox 29 Opera 19 IE9 Android 4
Data attribute 56.8 125.4 63.6 152.6 1455.2
Data attribute (qualified) 55.4 128.4 61.4 141 1404.6
Data attribute (unqualified but with value) 55 125.6 61.8 152.4 1363.4
Data attribute (qualified with value) 54.8 129 63.2 147.4 1421.2
Multiple data attributes (qualified with values) 55.4 124.4 63.2 147.4 1411.2
Solo pseudo selector (e.g. :after) 60.6 138 58.4 162 1500.4
Combined classes (e.g. class1.class2) 51.2 126.6 56.8 147.8 1453.8
Multiple classes 48.8 127.4 56.2 150.2 1398.8
Multiple classes with child selector 48.8 127.4 55.8 154.6 1348.4
Partial attribute matching (e.g. [class^=“wrap”]) 52.2 129.4 58 172 1420.2
nth-child selector 49 127.4 56.6 148.4 1352
nth-child selector followed by another nth-child selector 50.6 127.2 58.4 146.2 1377.6
Insanity selection (all selections qualified, every class used) 64.6 129.2 72.4 152.8 1461.2
Slight insanity selection (e.g. .tagLi .tagB a.TagA.link) 50.2 129.8 54.8 154.6 1381.2
Universal selector 50 126.2 56.8 154.8 1351.6
Element single 49.2 127.6 56 149.2 1379.2
Element double 50.4 132.4 55 157.6 1386
Element treble 49.2 128.8 58.6 154.2 1380.6
Element treble with pseudo 48.6 132.4 54.8 148.4 1349.6
Single class 50.4 128 55 149.8 1393.8
Biggest Diff 16 13.6 17.6 31 152
Biggest Diff 13 6 13 10 6
48.
body
p imgspan
span
body { font-size: 16px; }
p { font-weight: bold; }
span { color: red; }
p span { display: none; }
img { float: right; }
font-size: 16px;
font-size: 16px;
float: right;
font-size: 16px;
font-weight: bold;
font-size: 16px;
font-weight: bold;
display: none;
font-size: 16px;
color: red;
BROWSER WebKit CSS OBJECT MODEL
CSS Object Model
RENDERING ENGINE
49.
DOM
BROWSER WebKit STYLE RULES
WebKit
RENDERING ENGINE
50.
DOM
BROWSER RENDERING ENGIN WebKit ATTACHMENT
WebKit
RENDERING ENGINE
51.
Attachment
CSSOMDOM
BODY
p
I am in p
div
img
font-size: 16px;
font-size: 16px;
float: right;
font-size: 16px;
font-weight: bold;
BROWSER WebKit ATTACHMENTRENDERING ENGINE
52.
DOM
BROWSER WebKit RENDER TREE
WebKit
RENDERING ENGINE
53.
DOM
BROWSER WebKit RENDER TREE LAYOUT / REFLOW & PAINTING
WebKit
RENDERING ENGINE
54.
Layout / Reflow
calculating position and size of renderers
Painting
BROWSER WebKit RENDER TREE LAYOUT / REFLOW & PAINTINGRENDERING ENGINE
61.
61
Summary
● Latency matters
● Browser is not so simple
● CSS selectors can be a tricky place
● Resources amount matters
● Every millisecond means a lot