-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
360 lines (285 loc) · 11.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>KISS - Keep it smooth stupid</title>
<meta name="description" content="">
<meta name="author" content="b">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/default.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<link rel="stylesheet" href="css/styles.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<div class="slides">
<section class="intro-slide">
<h1>KISS</h1>
<p>(keep it smooth stupid)</p>
<h2>Frontend performance<br> on web applications</h2>
<p>
<small>by André Cruz / <a href="http://twitter.com/satazor">@satazor</a></small>
</p>
</section>
<section class="performance-slide" data-background="#007777">
<h2>Performance</h2>
<p>Is an ambigious word, depends on what we are trying to achieve</p>
<table>
<tr>
<th>Aircraft</th>
<th>Capacity</th>
<th>Range <span>miles</span></th>
<th>Speed <span>mph</span></th>
<th>Debit <span>cap x mph</span></th>
</tr>
<tr>
<td>Boeing 777</td>
<td>375</td>
<td>4630</td>
<td>610</td>
<td>228.700</td>
</tr>
<tr>
<td>Boeing 747</td>
<td><strong>470</strong></td>
<td>4150</td>
<td>610</td>
<td><strong>286.700</strong></td>
</tr>
<tr>
<td>Concorde</td>
<td>132</td>
<td>4000</td>
<td><strong>1350</strong></td>
<td>178.200</td>
</tr>
<tr>
<td>DC-8-50</td>
<td>146</td>
<td><strong>8720</strong></td>
<td>544</td>
<td>179.424</td>
</tr>
</table>
<aside class="notes">
<ul>
<li>Performance é uma palavra ambígua, depende das condições e objectivos</li>
<li>Qual o melhor avião? Qual é o que tem melhor performance?</li>
</ul>
</aside>
</section>
<section class="performance-on-web-slide" data-background="#836953">
<h2>Performance on the web</h2>
<p>.. really matters</p>
<ul>
<li>User demands and expectations are high</li>
<li>Users don't like slow and slugish experience</li>
<li>New technology empower us to make rich and interactive web applications</li>
</ul>
</section>
<section class="areas-slide" data-background="#B1361E">
<div class="col">
<h2>Page load</h2>
<ul>
<li>SPDY / HTTP 2</li>
<li>Concat + minify JS & CSS</li>
<li>GZIP</li>
<li>CDN</li>
<li>Image sprites</li>
<li>Cache-busting</li>
<li>Lazy load</li>
<li>Scripts at the end & styles at the start</li>
</ul>
</div>
<div class="col">
<h2>Runtime</h2>
<ul>
<li>Transitions & animations</li>
<li>Scrolling</li>
<li>Resizing</li>
<li>Number of DOM elements</li>
<li>DOM rendering & manipulation</li>
<li>Memory & GC</li>
</ul>
</div>
<aside class="notes">
<ul>
<li>Performance nas aplicações resume-se a duas fases: Page load e Runtime</li>
<li>YSlow da YAHOO ajuda no Pageload</li>
<li>DevTools ajuda no Pageload mas principalmente no Runtime</li>
</ul>
</aside>
</section>
<section class="rendering-ops" data-background="#444837">
<h2>Rendering operations</h2>
<div class="col">
<ul>
<li>Recalculate style</li>
<li>Layout</li>
<li>Paint setup & Paint</li>
<li>Composite layers</li>
</ul>
</div>
<div class="col">
<img src="img/devtools.png" alt="DevTools">
</div>
<p>All of this in <16ms on a 60hz monitor to avoid losing frames</p>
<aside class="notes">
<ul>
<li>Sequencia de operações de renderização</li>
<li>Em geral, funciona em waterfall mas pode começar directamente numa das fases</li>
</ul>
</aside>
</section>
<section data-background="#444837">
<h2>Recalculate style</h2>
<p>Matches the CSS styles with the DOM structure</p>
<p>Everytime a CSS property changes</p>
<p>Usually a fast operation, slower on complex CSS selectors</p>
</section>
<section data-background="#444837">
<h2>Layout</h2>
<p>Calculation of positions and geometry</p>
<p>When certain CSS properties change, e.g.: width, height, top, left, margin</p>
<p>Takes longer when the DOM structure is very complex</p>
</section>
<section data-background="#444837">
<h2>Paint Setup & Paint</h2>
<p>Fill out the pixels for each element into layers</p>
<p>When certain CSS properties change, e.g.: color, border-radius, background</p>
<p>Takes longer when using inefficient styles</p>
<p>Slower on low end devices</p>
</section>
<section data-background="#444837">
<h2>Composite layers</h2>
<p>Draw layers into the screen</p>
<p>When certain CSS properties change, e.g.: transform, opacity</p>
<p>Very cheap to do</p>
</section>
<section data-background="#444837">
<img src="img/devtools2.jpg" alt="DevTools properties">
</section>
<section class="holy-grail-anim-slide" data-background="#4B4B65">
<h2>Animate like a boss</h2>
<img src="img/likeaboss.png" alt="Like a boss">
<p>Animate properties that only require Composite Layers.</p>
<p>Avoid others, specially the ones that require Layout.</p>
</section>
<section class="cheap-ops-slide" data-background="#4B4B65">
<h2>Animate like a boss</h2>
<img src="img/cheap-operations.jpg" alt="Cheap operations">
</section>
<section class="cheap-ops-slide" data-background="#4B4B65">
<h2>Animate like a boss</h2>
<a href="examples/animations/index.html" target="_blank">DEMO</a>
</section>
<section data-background="#0E400D">
<h2>Layout trashing</h2>
<p>When the DOM is modified via JavaScript it is marked as dirty. The browser is lazy and wants to wait until the end of current operation or frame to handle the modifications</p>
<p>If we ask for a value back from the DOM before that we force the browser to handle it early</p>
<p>If you abuse it, you are doing layout trashing</p>
</section>
<section class="layout-trash-code-slide" data-background="#0E400D" data-markdown>
<script type="text/template">
## Layout trashing
```js
var slideEl = $('.slide');
// BAD - read, write, read, write
slideEl.width(slideEl.height());
slideEl.css('margin', slideEl.parent().height());
```
```js
var slideEl = $('.slide');
var height = slideEl.height();
var parentHeight = slideEl.parent().height();
// GOOD - read, read, write, write
slideEl.width(height);
slideEl.css('margin', parentHeight);
```
<a href="examples/layout_trashing/index.html" target="_blank">DEMO</a>
</script>
</section>
<section data-background="#0E400D">
<h2>Layout trashing</h2>
<p>More severe in a large decoupled code base where each component handle its rendering and measurement independently.</p>
<p>To counter this you may use <a href="https://github.com/wilsonpage/fastdom">FastDom</a>, a library that queues reading and writing operations and groups them.</p>
</section>
<section data-background="#B1361E">
<h2>Scroll</h2>
<p>Avoid expensive styles that slow down painting</p>
<p>GPU accelerate the layer with transform: translateZ(0)</p>
<p><a href="http://www.thecssninja.com/javascript/pointer-events-60fps" target="_blank">Turn off</a> hover effects that may trigger during scroll</p>
<p>Don't do anything more than getting a scroll offset in the scroll event handler, delay the rest to a requestAnimationFrame or use a throttler</p>
<p>On mobile, overflow: auto performs poorly, use <a href="http://css-tricks.com/snippets/css/momentum-scrolling-on-ios-overflow-elements/" target="_blank">-webkit-overflow-scrolling: touch</a></p>
</section>
<section data-background="#B1361E">
<h2>Scroll</h2>
<a href="examples/scroll/index.html" target="_blank">DEMO</a>
</section>
<section data-background="#007777">
<h2>Resize</h2>
<p>Turn off animations during the resize</p>
<p>Avoid doing a lot of work, delay stuff using requestAnimationFrame or use a throttler</p>
<p>Pay special attention to layout trashing when adapting to resolutions dynamically via JavaScript</p>
</section>
<section data-background="#444837">
<h2>Memory & GC</h2>
<p>Avoid unnecessary allocations of objects, arrays or other structures</p>
<p>GC blocks the main thread which usually also blocks the UI thread</p>
<p>The higher the unnecessary memory allocated, the longer the Gargabe Collection cycle will take</p>
<p>If your memory is unexpectedly high, check for memory leaks using the <a href="https://developer.chrome.com/devtools/docs/javascript-memory-profiling" target="_blank">DevTools Memory profiling</a></p>
</section>
<section>
<h2>Do not guess, test it!</h2>
<p>Because browsers are always evolving and the things you know today may no longer apply<p>
<p>Each case should be treated separately</p>
</section>
<section data-background="img/thatsall.jpg">
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
// Full list of configuration options available here:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
// Parallax scrolling
// parallaxBackgroundImage: 'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg',
// parallaxBackgroundSize: '2100px 900px',
// Optional libraries used to extend on reveal.js
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
{ src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
]
});
</script>
</body>
</html>