-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1314 lines (1145 loc) · 60.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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Pacifico|Shadows+Into+Light" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Lobster+Two:400,700" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="jspm_packages/github/hakimel/[email protected]/css/reveal.css">
<link rel="stylesheet" href="jspm_packages/github/hakimel/[email protected]/css/theme/white.css">
<link rel="stylesheet" href="src/css/common.css">
<link rel="stylesheet" href="src/css/solarized-light.css">
</head>
<body>
<div class="reveal">
<div class="slides">
<section data-background-image="src/img/techtalk_rewolucja_web_grafika_do_wydarzenia_v2.png" data-background-size="90%">
</section>
<section>
<h2 style="margin-bottom: -0.25em">Are we going to talk about frameworks?</h2>
<div>
<img class="plain" style="max-height: 3.5em; margin: 0.5em" src="src/img/angular-logo.png">
<img class="plain" style="max-height: 3.5em; margin: 0.5em" src="src/img/react-logo.png">
<img class="plain" style="max-height: 3.5em; margin: 0.5em" src="src/img/vue-logo.png">
</div>
<div>
<img class="plain" style="max-height: 3.5em; margin: 0.5em" src="src/img/aurelia-logo.png">
<img class="plain" style="max-height: 3.5em; margin: 0.5em" src="src/img/ember-logo.png">
<img class="plain" style="max-height: 3.5em; margin: 0.5em" src="src/img/backbone-logo.png">
</div>
<div>
<img class="plain" style="max-height: 3.5em; margin: 0.5em" src="src/img/jquery-logo.png">
<img class="plain" style="max-height: 3.5em; margin: 0.5em" src="src/img/logo-d3.png">
<img class="plain" style="max-height: 3.5em; margin: 0.5em" src="src/img/polymer-logo.png">
</div>
</section>
<section>
<h2>Not much ...</h2>
<h2>we are going to focus on the platform</h2>
<div>
<img class="plain" style="max-height: 4em; margin: 0.5em" src="src/img/chrome-icon.png">
<img class="plain" style="max-height: 4em; margin: 0.5em" src="src/img/firefox-logo.png">
<img class="plain" style="max-height: 4em; margin: 0.5em" src="src/img/safari-logo.png">
</div>
<div>
<img class="plain" style="max-height: 4em; margin: 1em" src="src/img/edge-logo.png">
<img class="plain" style="max-height: 4em; margin: 1em" src="src/img/opera-logo.png">
</div>
</section>
<section>
<img class="plain" style="max-height: 14em; margin: 0.5em" src="src/img/browser.png">
<div style="position:fixed; top:5em; left: 2em" class="fragment action-box blue-box">
<p>ECMAScript 6</p>
</div>
<div style="position:fixed; top:10em; left: 2em" class="fragment action-box red-box">
<p>WebComponents</p>
</div>
<div style="position:fixed; top:5em; left: 16em" class="fragment action-box yellow-box">
<p>Cache/Storage</p>
</div>
<div style="position:fixed; top:1em; left: 16em" class="fragment action-box green-box">
<p>Service Workers</p>
</div>
<div style="position:fixed; top:9em; left: 16em" class="fragment action-box purple-box">
<p>Web APIs</p>
</div>
<div style="position:fixed; top: 0em; left: 12em; width: 50%; height: 90%" class="fragment">
<p class="grey-bg"></p>
<p class="grey-box">Progressive Web Apps</p>
</div>
</section>
<section class="agenda">
<img class="plain" style="max-height: 14em; margin: 0.5em" src="src/img/browser.png">
<div style="position:fixed; top:5em; left: 2em" class="action-box blue-box">
<p>ECMAScript 6</p>
</div>
<div style="position:fixed; top:10em; left: 2em" class="action-box red-box disabled">
<p>WebComponents</p>
</div>
<div style="position:fixed; top:5em; left: 16em" class="action-box yellow-box disabled">
<p>Cache/Storage</p>
</div>
<div style="position:fixed; top:1em; left: 16em" class="action-box green-box disabled">
<p>Service Workers</p>
</div>
<div style="position:fixed; top:9em; left: 16em" class="action-box purple-box disabled">
<p>Web APIs</p>
</div>
<div style="position:fixed; top: 0em; left: 12em; width: 50%; height: 90%" class="disabled">
<p class="grey-bg"></p>
<p class="grey-box">Progressive Web Apps</p>
</div>
</section>
<section>
<img src="src/img/js-logo-small.png">
<h1 style="font-size: 4.5em; margin-bottom: -0.25em;" class="primaryColor" >What's</h1>
<h1 style="font-size: 3em; margin-bottom: -0.25em;" class="fallbackColor" >new?</h1>
</section>
<section data-background-color="var(--secondary-color)">
<h1 style="font-size: 3em; margin-bottom: -0.25em;" class="fallbackColor">We have</h1>
<h1 style="font-size: 3.5em; text-transform: none" class="flippedColor" >ECMAScript 2015!</h1>
<h1 style="font-size: 1.5em; margin-bottom: -0.25em; text-transform: none" class="primaryColor" >Let's go through a few of its highlights...</h1>
</section>
<section>
<section>
<h3>ES2015 Classes</h3>
<pre><code class="javascript" data-trim data-noescape>
class Shape {
constructor(x, y) {
this.move(x, y);
}
move(x, y) {
this.x = x;
this.y = y;
}
}
class Rectangle extends Shape {
constructor(x, y, width, height) {
super(x, y);
this.width = width;
this.height = height;
}
}
</code></pre>
<p>
<a href="http://es6-features.org/" class="credits" target="_blank">Code examples from http://es6-features.org/</a>
</p>
</section>
<section>
<h3>ES5 Constructor Functions and Prototypal Inheritance</h3>
<pre><code class="javascript" data-trim data-noescape>
var Shape = function (x, y) {
this.move(x, y);
};
Shape.prototype.move = function (x, y) {
this.x = x;
this.y = y;
};
var Rectangle = function (width, height) {
this.width = width;
this.height = height;
};
Rectangle.prototype = new Shape(1, 5);
var smallRectangle = new Rectangle(10, 20);
</code></pre>
<p>
<a href="http://es6-features.org/" class="credits" target="_blank">Code examples from http://es6-features.org/</a>
</p>
</section>
</section>
<section>
<section>
<h3>ES2015 Arrow Functions / Lexical <span style="font-family: monospace">this</span></h3>
<pre><code class="javascript" data-trim data-noescape>
class Classroom {
constructor() {
this.students = [
{name: 'Joe', isMyFriend: false},
{name: 'Eric', isMyFriend: true}];
this.anyFriendThere = false;
}
checkIfAnyFriendThere() {
this.students.forEach((student) => {
if (student.isMyFriend) {
this.anyFriendThere = true;
}
});
}
}
</code></pre>
<p>
<a href="http://es6-features.org/" class="credits" target="_blank">Code examples from http://es6-features.org/</a>
</p>
</section>
<section>
<h3>ES5 <span style="font-family: monospace">bind()</span></h3>
<pre><code class="javascript" data-trim data-noescape>
var classroom = {
students: [
{name: 'Joe', isMyFriend: false},
{name: 'Eric', isMyFriend: true}],
anyFriendThere: false,
checkIfAnyFriendThere: function () {
this.students.forEach(function (student) {
if (student.isMyFriend) {
this.anyFriendThere = true;
}
}.bind(this)); // binds this to the function context
}
};
</code></pre>
<p>
<a href="http://es6-features.org/" class="credits" target="_blank">Code examples from http://es6-features.org/</a>
</p>
</section>
<section>
<img src="src/img/ben-halpern-tweet.png">
</section>
</section>
<section>
<section>
<h3>ES2015 Promises</h3>
<pre><code class="javascript" data-trim data-noescape>
let sayHello = function (name) {
return new Promise(function (resolve, reject) {
setTimeout(() => resolve(`Hello ${name}`), 1000);
});
};
sayHello('Joe')
.then((helloToJoe) => {
console.log(`Someone says: ${helloToJoe}`);
return sayHello('Eric');
})
.then((helloToEric) => {
console.log(`Someone says: ${helloToEric}`);
});
</code></pre>
<p>
<a href="http://es6-features.org/" class="credits" target="_blank">Code examples from http://es6-features.org/</a>
</p>
</section>
<section>
<h3>ES5 callbacks</h3>
<pre><code class="javascript" data-trim data-noescape>
var sayHello = function (name, onSuccess) {
setTimeout(function () {
onSuccess('Hello ' + name);
}, 1000);
};
sayHello('Joe', function (helloToJoe) {
console.log('Someone says: ' + helloToJoe);
sayHello('Eric', function (helloToEric) {
console.log('Someone says: ' + helloToEric);
});
});
</code></pre>
<p>
<a href="http://es6-features.org/" class="credits" target="_blank">Code examples from http://es6-features.org/</a>
<a href="http://es6-features.org/" class="credits" target="_blank">Code examples from http://es6-features.org/</a>
</p>
</section>
</section>
<section>
<section>
<h3>ES2015 Module Exports / Imports</h3>
<pre><code class="javascript" data-trim data-noescape>
// greeter.js
export function sayHelloTo(name) {
return `Hello ${name}`;
}
// my-code.js
import {sayHelloTo} from './greeter';
console.log(sayHelloTo('Joe'));
</code></pre>
<p>
<a href="http://es6-features.org/" class="credits" target="_blank">Code examples from http://es6-features.org/</a>
</p>
</section>
<section>
<h3>ES5 Namespace Pattern</h3>
<pre><code class="javascript" data-trim data-noescape>
// greeter.js
var myNamespace = {};
myNamespace.sayHelloTo = function (name) {
return `Hello ${name}`;
};
// my-code.js
console.log(myNamespace.sayHelloTo('Joe'));
</code></pre>
<p>
<a href="http://es6-features.org/" class="credits" target="_blank">Code examples from http://es6-features.org/</a>
</p>
</section>
</section>
<section>
<h1 style="font-size: 2em" class="fallbackColor" >We have even more than ES2015...</h1>
<img src="src/img/ts-logo.svg" style="border: none; box-shadow: none">
</section>
<section>
<h3>Typical Angular 2 Component</h3>
<pre><code class="javascript" data-trim data-noescape>
import {Input, Component} from '@angular/core';
@Component({
selector: 'hello',
template: '<h1>Hello {{name}}!</h1>'
} as Component)
export class HelloComponent {
@Input()
name: string;
}
</code></pre>
</section>
<section>
<img src="src/img/tools.png" style="border: none; box-shadow: none" height="500px">
<div>
<a href="https://medium.freecodecamp.com/javascript-fatigue-fatigue-66ffb619f6ce#.9nvy1k7i2" target="_blank"><span style="font-size: medium">JavaScript Fatigue Fatigue</span></a>
</div>
<div>
<a href="https://hackernoon.com/how-it-feels-to-learn-javascript-in-2016-d3a717dd577f#.9rg50y1k7" target="_blank"><span style="font-size: medium">How it feels to learn JavaScript in 2016</span></a>
</div>
</section>
<section class="agenda">
<img class="plain" style="max-height: 14em; margin: 0.5em" src="src/img/browser.png">
<div style="position:fixed; top:5em; left: 2em" class="action-box blue-box disabled">
<p>ECMAScript 6</p>
</div>
<div style="position:fixed; top:10em; left: 2em" class="action-box red-box">
<p>WebComponents</p>
</div>
<div style="position:fixed; top:5em; left: 16em" class="action-box yellow-box disabled">
<p>Cache/Storage</p>
</div>
<div style="position:fixed; top:1em; left: 16em" class="action-box green-box disabled">
<p>Service Workers</p>
</div>
<div style="position:fixed; top:9em; left: 16em" class="action-box purple-box disabled">
<p>Web APIs</p>
</div>
<div style="position:fixed; top: 0em; left: 12em; width: 50%; height: 90%" class="disabled">
<p class="grey-bg"></p>
<p class="grey-box">Progressive Web Apps</p>
</div>
</section>
<section>
<img src="src/img/web-components-logo.svg" style="border: none; box-shadow: none">
<h1 style="font-size: 3em;" class="primaryColor" >Web Components</h1>
<h1 style="font-size: 1.5em; margin-bottom: -0.25em; text-transform: none" class="fallbackColor" >Dreams do come true...</h1>
</section>
<section>
<h1 style="font-size: 1.75em; text-transform: none;" class="primaryColor" >We've come a long way...</h1>
<img src="src/img/web-components-history.png" style="border: none; box-shadow: none" height="450px">
<div>
<a href="https://entwickler.de/java-magazin/java-magazin-7-15-135464.html?kiosk=1" target="_blank"><span style="font-size: small">Von Kompositionen und Arrangements, Patrick Hillert, Java Magazin 7.15</span></a>
</div>
</section>
<section>
<section>
<div>
<img src="src/img/icon-templates.png" style="border: none; box-shadow: none;">
<h1>Templates</h1>
</div>
</section>
<section>
<pre><code class="html" data-trim data-noescape>
<template id="my-template">
<div>
<p>This is my template</p>
</div>
</template>
</code></pre>
<pre style="margin-top: 30px;"><code class="javascript" data-trim data-noescape>
var template = document.querySelector('#my-template'),
clone = document.importNode(template.content, true);
document.body.appendChild(clone);
</code></pre>
<a href="src/web-components/templates.html" target="_blank">Demo </></a>
</section>
</section>
<section>
<section>
<div>
<img src="src/img/icon-shadowdom.png" style="border: none; box-shadow: none;">
<h1>Shadow DOM</h1>
</div>
</section>
<section>
<pre><code class="html" data-trim data-noescape>
<template id="my-template">
<div><p>This is my template</p></div>
</template>
<div id="john">
<p>John</p>
</div>
<div id="eric">
<p>Eric</p>
</div>
</code></pre>
<pre style="margin-top: 30px;"><code class="javascript" data-trim data-noescape>
var template = document.querySelector('#my-template'),
host = document.querySelector('#eric'),
root = host.attachShadow({mode: 'closed'}),
clone = document.importNode(template.content, true);
root.appendChild(clone);
</code></pre>
<a href="src/web-components/shadow-dom.html" target="_blank">Demo </></a>
</section>
</section>
<section>
<section>
<div>
<img src="src/img/icon-customelements.png" style="border: none; box-shadow: none;">
<h1>Custom Elements</h1>
</div>
</section>
<section>
<pre><code class="html" data-trim data-noescape>
<my-template></my-template>
<my-template></my-template>
<my-template></my-template>
<template id="my-template">
<div><p>This is my template</p></div>
</template>
</code></pre>
<pre style="margin-top: 30px;"><code class="javascript" data-trim data-noescape>
var myTemplateHtmlElement = Object.create(HTMLElement.prototype);
myTemplateHtmlElement.createdCallback = function () {
var template = document.querySelector('#my-template'),
clone = document.importNode(template.content, true),
root = this.attachShadow({mode: 'closed'});
root.appendChild(clone);
};
document.registerElement("my-template",
{prototype: myTemplateHtmlElement});
</code></pre>
<a href="src/web-components/custom-elements.html" target="_blank">Demo </></a>
</section>
</section>
<section>
<section>
<div>
<img src="src/img/icon-htmlimports.png" style="border: none; box-shadow: none;">
<h1>HTML Imports</h1>
</div>
</section>
<section>
<pre><code class="html" data-trim data-noescape>
<head>
<link rel="import" href="my-template/my-template.html">
</head>
<body>
<my-template></my-template>
<my-template></my-template>
<my-template></my-template>
</body>
</code></pre>
<a href="src/web-components/html-imports.html" target="_blank">Demo </></a>
</section>
</section>
<section>
<h2 class="fallbackColor" style="text-transform: none;">We're supposed to focus more on the platform and not on frameworks, aren't we?</h2>
<h1 style="font-size: 2.5em; margin-bottom: -0.25em;" class="secondaryColor" >Yes, we are, but...</h1>
</section>
<section data-background-color="var(--secondary-color)">
<h1 style="font-size: 5em; margin-bottom: -0.4em;" class="fallbackColor" >Let's</h1>
<h1 style="font-size: 4.8em; margin-bottom: -0.25em;" class="primaryColor" >Get Rid Of</h1>
<h1 style="font-size: 3em;" class="flippedColor" >the Boilerplate</h1>
</section>
<section>
<img src="src/img/polymer-logo.png" style="border: none; box-shadow: none" height="100px">
<pre><code class="html" data-trim data-noescape>
<link rel="import"
href="https://polygit.org/components/polymer/polymer.html">
<dom-module id="my-template">
<template>
<div><p>This is my template</p></div>
</template>
<script>
Polymer({
is: "my-template"
});
</script>
</dom-module>
</code></pre>
<a href="src/web-components/polymer.html" target="_blank">Demo </></a>
</section>
<section class="agenda">
<img class="plain" style="max-height: 14em; margin: 0.5em" src="src/img/browser.png">
<div style="position:fixed; top:5em; left: 2em" class="action-box blue-box disabled">
<p>ECMAScript 6</p>
</div>
<div style="position:fixed; top:10em; left: 2em" class="action-box red-box disabled">
<p>WebComponents</p>
</div>
<div style="position:fixed; top:5em; left: 16em" class="action-box yellow-box">
<p>Cache/Storage</p>
</div>
<div style="position:fixed; top:1em; left: 16em" class="action-box green-box disabled">
<p>Service Workers</p>
</div>
<div style="position:fixed; top:9em; left: 16em" class="action-box purple-box">
<p>Web APIs</p>
</div>
<div style="position:fixed; top: 0em; left: 12em; width: 50%; height: 90%" class="disabled">
<p class="grey-bg"></p>
<p class="grey-box">Progressive Web Apps</p>
</div>
</section>
<section data-background-color="var(--secondary-color)">
<h1 style="font-size: 4.9em; margin-bottom: -0.25em;" class="fallbackColor" >Offline</h1>
<h1 style="font-size: 4.5em; margin-bottom: -0.25em;" class="primaryColor" >caching</h1>
<h1 style="font-size: 4.1em;" class="flippedColor" >dilemma</h1>
</section>
<section>
<h3>AppCache lottery</h3>
<ul class="no-bullets">
<li>Files <span class="secondaryColor">always</span> come from cache</li>
<li>Application updates <span class="secondaryColor">only</span> on manifest <span class="secondaryColor">content change</span></li>
<li>Additional <span class="secondaryColor">not</span> alternative cache</li>
<li><span class="secondaryColor">Non-cached</span> resources do <span class="secondaryColor">not load</span> on <span class="secondaryColor">cached</span> page</li>
<li><strong><span class="secondaryColor">Lack of JavaScript API</span></strong></li>
</ul>
<p>
<a href="http://alistapart.com/article/application-cache-is-a-douchebag" class="credits" target="_blank">Full article by Jake Archibald</a>
</p>
</section>
<section>
<h2 style="margin-top: -5em;">Web storage</h2>
<div class="replacement">
<div style="margin-top: 0em;" class="fragment fade-out" data-fragment-index="0">
<div style="border-top: 13em solid var(--secondary-color); border-right: 25.2em solid transparent;">
<h3 style="position:fixed; top:-1em;left:4em;color:white">localStorage</h3>
</div>
<div>
<h3 style="position:fixed; top:3em;left:11em">sessionStorage</h3>
</div>
<p>
<a href="https://www.html5rocks.com/en/tutorials/offline/storage/" class="credits" target="_blank">Introduction to offline storages</a>
</p>
</div>
<div style="margin-top: 1em;" class="fragment fade-in" data-fragment-index="0">
<div class="fragment fade-out" data-fragment-index="1">
<h3>localStorage</h3>
<ul class="no-bullets">
<li>Storing <span class="secondaryColor">smaller</span> amounts of data</li>
<li><span class="secondaryColor">Single</span> persistent object called localStorage</li>
<li><span class="secondaryColor">NoSQL</span> key-value store</li>
<li>Sync API</li>
<li><span class="secondaryColor">Poor</span> performance for <span class="secondaryColor">complex</span> data</li>
</ul>
</div>
</div>
<div style="margin-top: 1em;" class="fragment fade-in" data-fragment-index="1">
<h3>sessionStorage</h3>
<ul class="no-bullets">
<li>Similar to <span class="secondaryColor">localStorage</span></li>
<li><span class="secondaryColor">Cleans</span> when window/tab closed</li>
</ul>
</div>
</div>
</section>
<section>
<h3>IndexedDB</h3>
<ul class="no-bullets">
<li><span class="secondaryColor">Low-level API</span> for client-side storage</li>
<li>For <span class="secondaryColor">significant</span> amounts of <span class="secondaryColor">structured</span> data</li>
<li><span class="secondaryColor">High performance</span> searches of this data</li>
<li><span class="secondaryColor">Transactional</span> database system</li>
<li>JavaScript based <span class="secondaryColor">object-oriented</span> database</li>
<li>Operations done <span class="secondaryColor">async</span></li>
<li>Famous from <strong><span class="secondaryColor">complex</span></strong> API</li>
</ul>
<p>
<a href="https://www.html5rocks.com/en/tutorials/offline/storage/" class="credits" target="_blank">Introduction to offline storages</a>
</p>
</section>
<section>
<h3>'Cache' interface</h3>
<ul class="no-bullets">
<li>Storage mechanism for <span class="secondaryColor">Request / Response object pairs</span></li>
<li>Exposed to <span class="secondaryColor">window</span> and <span class="secondaryColor">workers</span></li>
<li>Items <span class="secondaryColor">do not</span> get updated <span class="secondaryColor"> unless explicitly</span> requested</li>
<li>Items <span class="secondaryColor">don’t expire</span> unless deleted</li>
<li>Origin can have <span class="secondaryColor">multiple</span>, named Cache objects</li>
<li><span class="secondaryColor">You</span> as a dev need to <span class="secondaryColor">purge</span> Cache entries</li>
</ul>
</section>
<section class="agenda">
<img class="plain" style="max-height: 14em; margin: 0.5em" src="src/img/browser.png">
<div style="position:fixed; top:5em; left: 2em" class="action-box blue-box disabled">
<p>ECMAScript 6</p>
</div>
<div style="position:fixed; top:10em; left: 2em" class="action-box red-box disabled">
<p>WebComponents</p>
</div>
<div style="position:fixed; top:5em; left: 16em" class="action-box yellow-box disabled">
<p>Cache/Storage</p>
</div>
<div style="position:fixed; top:1em; left: 16em" class="action-box green-box">
<p>Service Workers</p>
</div>
<div style="position:fixed; top:9em; left: 16em" class="action-box purple-box">
<p>Web APIs</p>
</div>
<div style="position:fixed; top: 0em; left: 12em; width: 50%; height: 90%" class="disabled">
<p class="grey-bg"></p>
<p class="grey-box">Progressive Web Apps</p>
</div>
</section>
<section data-background-color="var(--secondary-color)">
<h1 style="font-size: 2.0em; margin-bottom: 0.5em;" class="fallbackColor" >Service Workers</h1>
<h1 style="font-size: 2.3em; margin-bottom: -0.25em;" class="primaryColor" >Return power</h1>
<h1 style="font-size: 2.7em;" class="flippedColor" >to the devs!</h1>
</section>
<section>
<h3>Service Workers</h3>
<ul class="no-bullets">
<li>Give developers the <span class="secondaryColor">moving parts</span> to solve their problems</li>
<li>Alow to create <span class="secondaryColor">own caching patterns</span></li>
<li>Can only be used over <span class="secondaryColor">HTTPS</span> (excluding localhost)</li>
<li>Hijack connections</li>
<li>Fabricate, and filter responses</li>
</ul>
</section>
<section>
<h1 style="font-size: 2.4em; margin-bottom: 0em;" class="fallbackColor" >Wait wait wait!</h1>
<h1 style="font-size: 1.95em; margin-bottom: -0.25em;" class="primaryColor" >But what are those</h1>
<h1 style="font-size: 4em;" class="secondaryColor" >workers?</h1>
</section>
<section>
<h3>Workers</h3>
<ul class="no-bullets">
<li>Isolated thread</li>
<li>Code contained in <span class="secondaryColor">separate file</span> (async download)</li>
<li>Communication via message passing - <span class="secondaryColor">postMessage()</span></li>
<li>Messages <span class="secondaryColor">copied</span>, not shared</li>
<li>Same Origin</li>
</ul>
</section>
<section>
<h3>Main script:</h3>
<pre><code class="javascript" data-trim data-noescape>
var worker = new Worker('task.js');
worker.addEventListener('message', function(e) {
console.log('Worker said: ', e.data);
}, false);
worker.addEventListener('error', function(e){
console.log('ERROR: Line', e.lineno, 'in',
e.filename, ':', e.message);
}, false);
worker.postMessage('Hello World'); // Send data to our worker.
</code></pre>
<h3>task.js (the worker)</h3>
<pre><code class="javascript" data-trim data-noescape>
self.addEventListener('message', function(e) {
self.postMessage(e.data);
}, false);
</code></pre>
<p>
<a href="https://www.html5rocks.com/en/tutorials/workers/basics/" class="credits" target="_blank">Code from https://www.html5rocks.com/en/tutorials/workers/basics/</a>
</p>
</section>
<section>
<h3>Features Available to Workers</h3>
<ul class="no-bullets">
<li>The <span class="secondaryColor">navigator</span> object</li>
<li>The <span class="secondaryColor">location</span> object (read-only)</li>
<li>XMLHttpRequest</li>
<li>setTimeout()/clearTimeout() and setInterval()/clearInterval()</li>
<li>The Application <span class="secondaryColor">Cache</span></li>
<li>Importing <span class="secondaryColor">external scripts</span> using the importScripts() method</li>
<li><span class="secondaryColor">Spawning other</span> web workers</li>
</ul>
</section>
<section>
<h3>Workers do NOT have access to:</h3>
<ul class="no-bullets">
<li>The <span class="secondaryColor">DOM</span> (it's not thread-safe)</li>
<li>The <span class="secondaryColor">window</span> object</li>
<li>The <span class="secondaryColor">document</span> object</li>
<li>The <span class="secondaryColor">parent</span> object</li>
<li>will <span class="secondaryColor">not run locally</span> (e.g. from file://)</li>
</ul>
</section>
<section>
<h1 style="font-size: 2em; margin-bottom: 0em;" class="fallbackColor" >Now</h1>
<h1 style="font-size: 2.5em; margin-bottom: 0em;" class="primaryColor" >back to</h1>
<h1 style="font-size: 3em;" class="secondaryColor" >service workers</h1>
</section>
<section>
<h3>Service worker lifecycle</h3>
<p style="font-size: 0.5em; margin-top:-1em">(on first installation)</p>
<img class="plain" style="max-height: 11em;" src="src/img/sw-lifecycle.png">
<p>
<a href="https://developers.google.com/web/fundamentals/getting-started/primers/service-workers" class="credits" target="_blank">Image from Google Web Fundamentals</a>
</p>
</section>
<section>
<h3>Register a service worker</h3>
<pre><code class="javascript" data-trim data-noescape>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js')
.then(function(registration) {
// Registration was successful
console.log('Registration successful with scope: ',
registration.scope);
}).catch(function(err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
});
}
</code></pre>
<p>
<a href="https://developers.google.com/web/fundamentals/getting-started/primers/service-workers" class="credits" target="_blank">Code from Google Web Fundamentals</a>
</p>
</section>
<section>
<h3>Install a service worker</h3>
<pre><code class="javascript" data-trim data-noescape>
self.addEventListener('install', function(event) {
// Perform install steps
});
</code></pre>
<p>
<a href="https://developers.google.com/web/fundamentals/getting-started/primers/service-workers" class="credits" target="_blank">Code from Google Web Fundamentals</a>
</p>
</section>
<section data-background-color="var(--secondary-color)">
<h1 style="font-size: 2em; margin-bottom: 0em;" class="fallbackColor" >The</h1>
<h1 style="font-size: 2.5em; margin-bottom: 0em;" class="primaryColor" >cache</h1>
<h1 style="font-size: 3em;" class="flippedColor" >machine</h1>
</section>
<section>
<h3>On install - as a dependency</h3>
<img class="plain" style="max-height: 12em;" src="src/img/cm-on-install-dep.png">
<p>
<a href="https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/" class="credits" target="_blank">Image from Jake Archibald`s offline cookbook</a>
</p>
</section>
<section>
<h3>On install - as a dependency</h3>
<pre><code class="javascript" data-trim data-noescape>
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open('mysite-static-v3').then(function(cache) {
return cache.addAll([
'/css/whatever-v3.css',
'/css/imgs/sprites-v6.png',
'/css/fonts/whatever-v8.woff',
'/js/all-min-v4.js'
// etc
]);
})
);
});
</code></pre>
<p>
<a href="https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/" class="credits" target="_blank">Code from Jake Archibald`s offline cookbook</a>
</p>
</section>
<section>
<h3>On install - not as a dependency</h3>
<img class="plain" style="max-height: 12em;" src="src/img/cm-on-install-not.png">
<p>
<a href="https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/" class="credits" target="_blank">Image from Jake Archibald`s offline cookbook</a>
</p>
</section>
<section>
<h3>On install - not as a dependency</h3>
<pre><code class="javascript" data-trim data-noescape>
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open('mygame-core-v1').then(function(cache) {
cache.addAll(
// levels 11-20
);
return cache.addAll(
// core assets & levels 1-10
);
})
);
});
</code></pre>
<p>
<a href="https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/" class="credits" target="_blank">Code from Jake Archibald`s offline cookbook</a>
</p>
</section>
<section>
<h3>On activate - cleanup</h3>
<img class="plain" style="max-height: 12em;" src="src/img/cm-on-activate.png">
<p>
<a href="https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/" class="credits" target="_blank">Image from Jake Archibald`s offline cookbook</a>
</p>
</section>
<section>
<h3>On activate - cleanup</h3>
<pre><code class="javascript" data-trim data-noescape>
self.addEventListener('activate', function(event) {
event.waitUntil(
caches.keys().then(function(cacheNames) {
return Promise.all(
cacheNames.filter(function(cacheName) {
// Return true if you want to remove this cache,
// but remember that caches are shared across
// the whole origin
}).map(function(cacheName) {
return caches.delete(cacheName);
})
);
})
);
});
</code></pre>
<p>
<a href="https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/" class="credits" target="_blank">Code from Jake Archibald`s offline cookbook</a>
</p>
</section>
<section>
<h3>On user interaction</h3>
<img class="plain" style="max-height: 12em;" src="src/img/cm-on-user-interaction.png">
<p>
<a href="https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/" class="credits" target="_blank">Image from Jake Archibald`s offline cookbook</a>
</p>
</section>
<section>
<h3>On user interaction</h3>
<pre><code class="javascript" data-trim data-noescape>
document.querySelector('.cache-article')
.addEventListener('click', function(event) {
event.preventDefault();
var id = this.dataset.articleId;
caches.open('mysite-article-' + id)
.then(function(cache) {
fetch('/get-article-urls?id=' + id)
.then(function(response) {
return response.json();
}).then(function(urls) {
cache.addAll(urls);
});
});
});
</code></pre>
<p>
<a href="https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/" class="credits" target="_blank">Code from Jake Archibald`s offline cookbook</a>
</p>
</section>
<section>
<h1>And more ...</h1>
<img class="plain" style="max-height: 2.4em;" src="src/img/cm-on-network-response.png">
<img class="plain" style="max-height: 2.4em;" src="src/img/cm-stale-while-revalidate.png">
<img class="plain" style="max-height: 2.4em;" src="src/img/cm-on-push.png">
<img class="plain" style="max-height: 2.4em;" src="src/img/cm-on-bg-sync.png">
<img class="plain" style="max-height: 2.4em;" src="src/img/ss-cache-only.png">
<img class="plain" style="max-height: 2.4em;" src="src/img/ss-network-only.png">
<img class="plain" style="max-height: 2.4em;" src="src/img/ss-falling-back-to-network.png">
<img class="plain" style="max-height: 2.4em;" src="src/img/ss-cache-and-network-race.png">
<img class="plain" style="max-height: 2.4em;" src="src/img/ss-network-falling-back-to-cache.png">
<img class="plain" style="max-height: 2.4em;" src="src/img/ss-cache-then-network.png">
<img class="plain" style="max-height: 2.4em;" src="src/img/ss-generic-fallback.png">
<img class="plain" style="max-height: 2.4em;" src="src/img/ss-sw-side-templating.png">
<p>
<a href="https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/" class="credits" target="_blank">Images from Jake Archibald`s offline cookbook</a>
</p>
<p>
<a href="https://github.com/GoogleChrome/sw-toolbox" class="credits" target="_blank"><strong>SW Toolbox</strong> - no need to dive deep</a>
</p>
</section>
<section data-background-iframe="https://jakearchibald.github.io/isserviceworkerready/">
<h1 style="font-size: 3.0em;" class="fallbackColor" >Can we use <a href="https://jakearchibald.github.io/isserviceworkerready/">it</a>?</h1>
</section>
<section>
<h1>Push Notifications</h1>
<img class="plain" style="max-height: 12em;" src="src/img/cc-good.png">
<p>
<a href="https://developers.google.com/web/fundamentals/engage-and-retain/push-notifications/" class="credits" target="_blank">Image from Google Web Fundamentals</a>
</p>
</section>
<section class="agenda">
<img class="plain" style="max-height: 14em; margin: 0.5em" src="src/img/browser.png">
<div style="position:fixed; top:5em; left: 2em" class="action-box blue-box disabled">
<p>ECMAScript 6</p>
</div>
<div style="position:fixed; top:10em; left: 2em" class="action-box red-box disabled">
<p>WebComponents</p>
</div>
<div style="position:fixed; top:5em; left: 16em" class="action-box yellow-box">
<p>Cache/Storage</p>
</div>
<div style="position:fixed; top:1em; left: 16em" class="action-box green-box">
<p>Service Workers</p>
</div>
<div style="position:fixed; top:9em; left: 16em" class="action-box purple-box">
<p>Web APIs</p>
</div>
<div style="position:fixed; top: 0em; left: 12em; width: 50%; height: 90%">
<p class="grey-bg"></p>
<p class="grey-box">Progressive Web Apps</p>
</div>
</section>
<section>
<h3>Progressive Web Apps</h3>