-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1844 lines (1842 loc) · 89.2 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
<!DOCTYPE html>
<html lang='en'>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
<meta charset='utf-8'>
<title>We're breaking up with JavaScript frontends</title>
<meta content='yes' name='apple-mobile-web-app-capable'>
<meta content='black-translucent' name='apple-mobile-web-app-status-bar-style'>
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui' name='viewport'>
<link href='css/reveal.css' rel='stylesheet'>
<link href='css/theme/blood.css' id='theme' rel='stylesheet'>
<link href='css/custom.css' rel='stylesheet'>
<!-- Code syntax highlighting -->
<link href='lib/css/highlightjs/paraiso-dark.css' rel='stylesheet'>
<link href='pictures/favicon.png' rel='icon'>
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.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'>
<!-- Any section element inside of this container is displayed as a slide -->
<div class='slides'>
<section>
<h3>
<div class='subtle'>
It's not you, it's us
</div>
<div class='line'>
We're breaking up with JavaScript frontends
</div>
</h3>
<p>
Henning Koch, makandra GmbH
<br>
<a href='https://twitter.com/triskweline'>@triskweline</a>
</p>
</section>
<section>
<p>
Give it 10 minutes.
</p>
</section>
<section>
<h3>Context</h3>
<ul>
<li>makandra is a Ruby on Rails consultancy</li>
<li>We start a new application every 3 months</li>
<li>
We maintain apps for a <u>really</u> long time
<ul>
<li>50+ apps in maintenance</li>
<li>Oldest app is from 2007</li>
</ul>
</li>
<li>Will we be able to do this for another 10 years?</li>
</ul>
</section>
<section>
<h2>Tweet from 2025</h2>
<img src='pictures/future_tweet.png'>
</section>
<section>
<div class='complexity'>
<div class='complexity--title'>
Complexity
</div>
<div class='complexity--side'>
<div class='complexity--stack'></div>
<div class='complexity--side-name'>
Server
</div>
</div>
<div class='complexity--side'>
<div class='complexity--stack'></div>
<div class='complexity--side-name'>
Client
</div>
</div>
</div>
<p class='subtle xs' style='margin-top: 5px; text-align: center'>
Based on chart by <a href="https://twitter.com/ryanstout">@ryanstout</a>
</p>
</section>
<section>
<div class='complexity'>
<div class='complexity--title'>
Complexity in 2005
</div>
<div class='complexity--side'>
<div class='complexity--stack'>
<div class='complexity--slice is-color6 is-weight1'>
Authorization
</div>
<div class='complexity--slice is-color5 is-weight1'>
Routing
</div>
<div class='complexity--slice is-color4 is-weight3'>
Models
</div>
<div class='complexity--slice is-color3 is-weight2'>
Controllers
</div>
<div class='complexity--slice is-color2 is-weight2'>
Views
</div>
<div class='complexity--slice is-color1 is-weight2'>
Dependencies
</div>
</div>
<div class='complexity--side-name'>
Server
</div>
</div>
<div class='complexity--side'>
<div class='complexity--stack'></div>
<div class='complexity--side-name'>
Client
</div>
</div>
</div>
<p class='subtle xs' style='margin-top: 5px; text-align: center'>
Based on chart by <a href="https://twitter.com/ryanstout">@ryanstout</a>
</p>
</section>
<section>
<div class='complexity'>
<div class='complexity--title'>
Complexity in 2008
</div>
<div class='complexity--side'>
<div class='complexity--stack'>
<div class='complexity--slice is-color6 is-weight1'>
Authorization
</div>
<div class='complexity--slice is-color5 is-weight1'>
Routing
</div>
<div class='complexity--slice is-color4 is-weight4'>
Models
</div>
<div class='complexity--slice is-color3 is-weight2'>
Controllers
</div>
<div class='complexity--slice is-color2 is-weight4'>
Views
</div>
<div class='complexity--slice is-color1 is-weight2'>
Dependencies
</div>
</div>
<div class='complexity--side-name'>
Server
</div>
</div>
<div class='complexity--side'>
<div class='complexity--stack'>
<div class='complexity--slice is-color2 is-weight3'>
RandomJS
</div>
<div class='complexity--slice is-color1 is-weight1'>
Dependencies
</div>
</div>
<div class='complexity--side-name'>
Client
</div>
</div>
</div>
<p class='subtle xs' style='margin-top: 5px; text-align: center'>
Based on chart by <a href="https://twitter.com/ryanstout">@ryanstout</a>
</p>
</section>
<section>
<div class='complexity'>
<div class='complexity--title'>
Complexity in 2009
</div>
<div class='complexity--side'>
<div class='complexity--stack'>
<div class='complexity--slice is-color7 is-weight2'>
API
</div>
<div class='complexity--slice is-color6 is-weight1'>
Authorization
</div>
<div class='complexity--slice is-color5 is-weight1'>
Routing
</div>
<div class='complexity--slice is-color4 is-weight4'>
Models
</div>
<div class='complexity--slice is-color3 is-weight2'>
Controllers
</div>
<div class='complexity--slice is-color2 is-weight4'>
Views
</div>
<div class='complexity--slice is-color1 is-weight2'>
Dependencies
</div>
</div>
<div class='complexity--side-name'>
Server
</div>
</div>
<div class='complexity--side'>
<div class='complexity--stack'>
<div class='complexity--slice is-color2 is-weight6'>
RandomJS
</div>
<div class='complexity--slice is-color1 is-weight2'>
Dependencies
</div>
</div>
<div class='complexity--side-name'>
Client
</div>
</div>
</div>
<p class='subtle xs' style='margin-top: 5px; text-align: center'>
Based on chart by <a href="https://twitter.com/ryanstout">@ryanstout</a>
</p>
</section>
<section>
<div class='complexity'>
<div class='complexity--title'>
Complexity in 2011
</div>
<div class='complexity--side'>
<div class='complexity--stack'>
<div class='complexity--slice is-color8 is-weight1'>
Asset packing
</div>
<div class='complexity--slice is-color7 is-weight2'>
API
</div>
<div class='complexity--slice is-color6 is-weight1'>
Authorization
</div>
<div class='complexity--slice is-color5 is-weight1'>
Routing
</div>
<div class='complexity--slice is-color4 is-weight4'>
Models
</div>
<div class='complexity--slice is-color3 is-weight2'>
Controllers
</div>
<div class='complexity--slice is-color2 is-weight4'>
Views
</div>
<div class='complexity--slice is-color1 is-weight3'>
Dependencies
</div>
</div>
<div class='complexity--side-name'>
Server
</div>
</div>
<div class='complexity--side'>
<div class='complexity--stack'>
<div class='complexity--slice is-color2 is-weight9'>
RandomJS
</div>
<div class='complexity--slice is-color1 is-weight3'>
Dependencies
</div>
</div>
<div class='complexity--side-name'>
Client
</div>
</div>
</div>
<p class='subtle xs' style='margin-top: 5px; text-align: center'>
Based on chart by <a href="https://twitter.com/ryanstout">@ryanstout</a>
</p>
</section>
<section>
<div class='complexity'>
<div class='complexity--title'>
Complexity in 2013
</div>
<div class='complexity--side'>
<div class='complexity--stack'>
<div class='complexity--slice is-color8 is-weight1'>
Asset packing
</div>
<div class='complexity--slice is-color7 is-weight4'>
API
</div>
<div class='complexity--slice is-color6 is-weight1'>
Authorization
</div>
<div class='complexity--slice is-color5 is-weight1'>
Routing
</div>
<div class='complexity--slice is-color4 is-weight4'>
Models
</div>
<div class='complexity--slice is-color3 is-weight2'>
Controllers
</div>
<div class='complexity--slice is-color2 is-weight2'>
Views
</div>
<div class='complexity--slice is-color1 is-weight3'>
Dependencies
</div>
</div>
<div class='complexity--side-name'>
Server
</div>
</div>
<div class='complexity--side'>
<div class='complexity--stack'>
<div class='complexity--slice is-color4 is-weight5'>
Models / API client
</div>
<div class='complexity--slice is-color3 is-weight5'>
Controllers
</div>
<div class='complexity--slice is-color2 is-weight3'>
Views
</div>
<div class='complexity--slice is-color1 is-weight6'>
Dependencies
</div>
</div>
<div class='complexity--side-name'>
Client
</div>
</div>
</div>
<p class='subtle xs' style='margin-top: 5px; text-align: center'>
Based on chart by <a href="https://twitter.com/ryanstout">@ryanstout</a>
</p>
</section>
<section>
<div class='complexity'>
<div class='complexity--title'>
Complexity in 2014
</div>
<div class='complexity--side'>
<div class='complexity--stack'>
<div class='complexity--slice is-color8 is-weight1'>
Asset packing
</div>
<div class='complexity--slice is-color7 is-weight4'>
API
</div>
<div class='complexity--slice is-color6 is-weight1'>
Authorization
</div>
<div class='complexity--slice is-color5 is-weight1'>
Routing
</div>
<div class='complexity--slice is-color4 is-weight4'>
Models
</div>
<div class='complexity--slice is-color3 is-weight2'>
Controllers
</div>
<div class='complexity--slice is-color2 is-weight2'>
Views
</div>
<div class='complexity--slice is-color1 is-weight3'>
Dependencies
</div>
</div>
<div class='complexity--side-name'>
Server
</div>
</div>
<div class='complexity--side'>
<div class='complexity--stack'>
<div class='complexity--slice is-color6 is-weight1'>
Authorization
</div>
<div class='complexity--slice is-color5 is-weight2'>
Routing
</div>
<div class='complexity--slice is-color4 is-weight7'>
Models / API client
</div>
<div class='complexity--slice is-color3 is-weight6'>
Controllers
</div>
<div class='complexity--slice is-color2 is-weight3'>
Views
</div>
<div class='complexity--slice is-color1 is-weight7'>
Dependencies
</div>
</div>
<div class='complexity--side-name'>
Client
</div>
</div>
</div>
<p class='subtle xs' style='margin-top: 5px; text-align: center'>
Based on chart by <a href="https://twitter.com/ryanstout">@ryanstout</a>
</p>
</section>
<section>
<div class='complexity'>
<div class='complexity--title'>
Complexity in 2015
</div>
<div class='complexity--side'>
<div class='complexity--stack'>
<div class='complexity--slice is-color9 is-weight2'>
Prerendering
</div>
<div class='complexity--slice is-color8 is-weight1'>
Asset packing
</div>
<div class='complexity--slice is-color7 is-weight4'>
API
</div>
<div class='complexity--slice is-color6 is-weight1'>
Authorization
</div>
<div class='complexity--slice is-color5 is-weight1'>
Routing
</div>
<div class='complexity--slice is-color4 is-weight4'>
Models
</div>
<div class='complexity--slice is-color3 is-weight2'>
Controllers
</div>
<div class='complexity--slice is-color2 is-weight2'>
Views
</div>
<div class='complexity--slice is-color1 is-weight3'>
Dependencies
</div>
</div>
<div class='complexity--side-name'>
Server
</div>
</div>
<div class='complexity--side'>
<div class='complexity--stack'>
<div class='complexity--slice is-color7 is-weight2'>
Virtual DOM
</div>
<div class='complexity--slice is-color6 is-weight1'>
Authorization
</div>
<div class='complexity--slice is-color5 is-weight2'>
Routing
</div>
<div class='complexity--slice is-color4 is-weight7'>
Models / API client
</div>
<div class='complexity--slice is-color3 is-weight6'>
Controllers
</div>
<div class='complexity--slice is-color2 is-weight3'>
Views
</div>
<div class='complexity--slice is-color1 is-weight7'>
Dependencies
</div>
</div>
<div class='complexity--side-name'>
Client
</div>
</div>
</div>
<p class='subtle xs' style='margin-top: 5px; text-align: center'>
Based on chart by <a href="https://twitter.com/ryanstout">@ryanstout</a>
</p>
</section>
<section>
<p>
A look back at the 7 AngularJS projects that we wrote from 2013-2016:
</p>
<div class='project-dots'>
<div class='project-dots--row'>
<div class='project-dots--dot'>1</div>
<div class='project-dots--dot'>2</div>
<div class='project-dots--dot'>3</div>
<div class='project-dots--dot'>4</div>
<div class='project-dots--dot'>5</div>
<div class='project-dots--dot'>6</div>
<div class='project-dots--dot'>7</div>
</div>
</div>
<p>
</p>
</section>
<section>
<p>
In hindsight, these are the projects that should have been a SPA:
</p>
<div class='project-dots'>
<div class='project-dots--row'>
<div class='project-dots--dot'>1</div>
<div class='project-dots--dot is-positive'>2</div>
<div class='project-dots--dot'>3</div>
<div class='project-dots--dot is-positive'>4</div>
<div class='project-dots--dot'>5</div>
<div class='project-dots--dot'>6</div>
<div class='project-dots--dot'>7</div>
</div>
</div>
<p>
YMMV.
</p>
</section>
<section>
<h3>Learnings from 3 years of SPAs</h3>
<ol>
<li>
SPAs are a good fit for a certain class of UI.
<br>
For us that class is the exception, not the default.
</li>
<li>
There's a trade-off between UI fidelity and code complexity.
</li>
<li>
We think we can fix most of the problems with server-side apps
<br>
and find a new sweet spot in that trade-off.
</li>
</ol>
</section>
<section>
<img height='600' src='pictures/trade_off.png'>
</section>
<section>
<h3>
What server-side apps
<div class='green'>
do well
</div>
</h3>
<ol>
<li>Wide choice of great and mature languages</li>
<li>Low complexity stack</li>
<li>Synchronous data access</li>
<li>Time to first render</li>
<li>Works on low-end devices</li>
</ol>
</section>
<section>
<h3>
What server-side apps
<div class='red'>
don't do well
</div>
</h3>
<ol>
<li>Slow interaction feedback</li>
<li>
Page loads destroy transient state
<div class='subtle'>(scroll positions, unsaved form values, focus)</div>
</li>
<li>
Layered interactions are hard
<div class='subtle'>(modals, drop-downs, drawers)</div>
</li>
<li>Animation is complicated</li>
<li>Complex forms</li>
</ol>
</section>
<section>
<h3>Demo of server-side app issues</h3>
<p>
<a href='https://demo.unpoly.com/' target='_blank'>
Link to demo app
</a>
<br>
<span class='subtle'>(press <i>Start Classic</i> on first page)</span>
</p>
<br>
<h4>
Things to try and observe:
</h4>
<ul>
<li>
<div class='line'>Navigate between cards in the left pane</div>
<div class='red'>Scroll positions get lost in both panes</div>
</li>
<li>
<div class='line'>Open the second page ("More cards" link at the bottom of the left pane)</div>
<div class='red'>Card in the right pane gets lost</div>
</li>
<li>
<div class='line'>Edit a card, change the title, then change the pattern</div>
<div class='red'>Unsaved form content is gone when returning from the pattern selection</div>
</li>
</ul>
</section>
<section>
<h3>
<div class='line'>
How to fix server-side apps?
</div>
<div class='subtle'>
A thought experiment
</div>
</h3>
<img class='right' height='200' src='pictures/html6.png' style='margin-right: 120px'>
<p>
Imagine HTML6 was all about server-side apps
</p>
<p>
What features would be in that spec?
<br>
<span>
<span class='subtle'>Partial page updates?</span>
</span>
<br>
<span>
<span class='subtle'>Animated transitions?</span>
</span>
<br>
<span>
<span class='subtle'>Layered interactions?</span>
</span>
</p>
<p class='fragment'>
We can polyfill all of that!
<br>
<span class='subtle'>Because it's 2016 and JavaScript is now fast.</span>
</p>
</section>
<section>
<h2>
<img class='plain' src='pictures/logos/unpoly.png' width='50%'>
</h2>
<ul>
<li>25 new HTML attributes to write modern UI, but keep logic on the server</li>
<li>
<div class='line'>
Works with existing code
</div>
<div class='subtle'>
little to no changes required on the server side
</div>
</li>
<li>
Works with any backend language or framework
<div class='subtle'>
although we have some nice Rails bindings
</div>
</li>
<li>In development for two years and in production with multiple apps</li>
</ul>
</section>
<section>
<h3>Demo of Unpoly-enhanced app</h3>
<p>
<a href='https://demo.unpoly.com/' target='_blank'>
Link to demo app
</a>
<br>
<span class='subtle'>(press <i>Start Enhanced</i> on first page)</span>
</p>
<h4>
Things to try and observe:
</h4>
<ol>
<li>
<div class='line'>Navigate between cards, open and cancel the form</div>
<div class='green'>Page transitions are animated</div>
</li>
<li>
<div class='line'>Navigate between cards in the left pane</div>
<div class='green'>Scroll positions are kept in both panes</div>
</li>
<li>
<div class='line'>Open the second page ("More cards" link at the bottom of the left pane)</div>
<div class='green'>New page slides in smoothly</div>
<div class='green'>Card in the right pane is kept</div>
</li>
<li>
<div class='line'>Edit a card, change the title, then change the pattern</div>
<div class='green'>Pattern selection happens in a modal dialog, <br>preserving unsaved form values</div>
</li>
<li>
<div class='line'>Inspect links and see attributes with <code class='blue'>up-*</code> prefix</div>
<div class='gray'>
See docs for <a href="https://unpoly.com/a-up-target"><code>[up-target]</code></a> and
<a href="https://unpoly.com/up-modal"><code>[up-modal]</code></a>
</div>
</li>
</ol>
</section>
<section>
<h3>Classic page flow</h3>
<img src='pictures/fragment_flow_vanilla.svg' style='margin-bottom: 10px' width='100%'>
<p>
Server renders full pages on every request.
<br>
Any state that's not in the URL gets lost when switching pages.
</p>
</section>
<section>
<h3>Unpoly page flow</h3>
<img src='pictures/fragment_flow_unpoly.svg' style='margin-bottom: 10px' width='100%'>
<p>
Server <b>still renders full pages</b>, but we only use fragments.
<br>
This solves most of our problems with transient state being destroyed.
</p>
</section>
<section>
<h3>Layers</h3>
<div class='layers'>
<div class='layers--layer is-document'>
Document
<div class='layers--url'>
https://app/list
</div>
</div>
<div class='layers--layer is-modal'>
Modal
<div class='layers--url'>
https://app/new
</div>
</div>
<div class='layers--layer is-popup'>
Popup
<div class='layers--url'>
https://app/search
</div>
</div>
</div>
<p>Unpoly apps may stack up to three HTML pages on top of each other</p>
<p>Each layer has its own URL and can navigate without changing the others</p>
<p>Use this to <b>keep context</b> during interactions</p>
</section>
<section>
<img src='pictures/gmail.png'>
</section>
<section>
<img src='pictures/gmail_layers.png'>
</section>
<section>
<h3>Layers</h3>
<pre class='s'><code class='html' data-noescape><a href="/list" up-target=".main">Replace fragment</a>

<a href="/new" up-modal=".main">Open fragment in dialog</a>

<a href="/menu" up-popup=".main">Open fragment in dropdown</a>
</code></pre>
<p>Links in a layer prefer to update fragments within the layer</p>
<p>Changing a fragment behind the layer will close the layer</p>
</section>
<section>
<h3>Navigation</h3>
<ul>
<li>
All fragment updates change the browser URL by default.
</li>
<li>
<div class='line'>
Back/Forward buttons work as expected.
</div>
<div class='subtle'>
Even scroll positions are restored.
</div>
</li>
<li>
<div class='line'>
Linking to a fragment will <b>scroll the viewport</b> to reveal the fragment.
</div>
<div class='subtle'>
Unpoly is aware of fixed navigation bars and will scroll further/less.
</div>
</li>
<li>
Links to the current URL get an <a href="https://unpoly.com/up-current"><code>.up-current</code></a>
class automatically.
</li>
</ul>
</section>
<section>
<h3>But I have this really custom <span class="subtle">JavaScript / jQuery library / behavior</span> that I need to integrate</h3>
<p>
Don't worry, we actually allow for massive customization:
</p>
<ul>
<li>Pairing JavaScript snippets with HTML elements</li>
<li>Integrating libraries (WYSIWYG editor, jQuery plugins, ...)</li>
<li>Passing structured data to JavaScript snippets</li>
<li>Reuse existing Unpoly functionality from your own code</li>
<li>Invent your own UJS syntax</li>
<li>Configure defaults</li>
</ul>
</section>
<section>
<h3>Activating JS snippets</h3>
<p>
Every app needs a way to pair JavaScript snippets<br />with certain HTML elements:
</p>
<ul>
<li>A <code class='blue'>textarea.wysiwyg</code> should activate Redactor on load</li>
<li>
An <code class='blue'>input[type=search]</code> field should automatically request new results
<br>
when the user types something
</li>
<li>
A <code class='blue'>button.toggle-all</code> should toggle all checkboxes
when clicked
</li>
<li>
A <code class='blue'>.map</code> should render a map via the Google Maps JS API
</li>
</ul>
</section>
<section>
<h3>
<div class='line'>
Activating JS snippets
</div>
<div class='subtle'>
Random.js
</div>
</h3>
<pre><code class='html' data-noescape><div class="map"></span>




</code></pre>
<pre><code class='javascript' data-noescape>document.addEventListener('DOMContentLoaded', function(event) {
 document.querySelectorAll('.map').forEach(function(element) {
 new google.maps.Map(element)
 })
})
</code></pre>
<p>
This is what you see in JavaScript tutorials.
<br>
<span class='red'>HTML fragments loaded via AJAX don't get Javascriptified.</span>
</p>
</section>
<section>
<h3>
<div class='line'>
Activating JS snippets
</div>
<div class='subtle'>
Unpoly
</div>
</h3>
<pre><code class='html' data-noescape><div class="map"></span>




</code></pre>
<pre><code class='javascript' data-noescape>up.compiler('.map', function(element) {
 new google.maps.Map(element)
})


</code></pre>
<p>
Unpoly automatically compiles all fragments that it inserts or updates.
<br>
On the first page load, the entire document is compiled.
</p>
</section>
<section>
<h3>
<div class='line'>Getting data into your JS</div>
<div class='subtle'>Random.js</div>
</h3>
<pre><code class='html' data-noescape><div class="map"></div>

<script type="text/javascript">
 initMap(document.querySelector('.map'), { lat: 48.75, lng: 11.45 })
</script>
</code></pre>
<pre><code class='javascript' data-noescape>function initMap(element, center) {
 new google.maps.Map(element, { center: center })
})


</code></pre>
<p>
<br>
</p>
</section>
<section>
<h3>
<div class='line'>Getting data into your JS</div>
<div class='subtle'>Unpoly</div>
</h3>
<pre><code class='html' data-noescape><div class="map" up-data="{ lat: 48.75, lng: 11.45 }"</div>
 
 
 
 
</code></pre>
<pre><code class='javascript' data-noescape>up.compiler('.map', function(element, center) {
 new google.maps.Map(element, center: center)
})


</code></pre>
<p>
The <code class='blue'>[up-data] </code> attribute value is parsed as JSON and passed
<br>
to your compiler as a JavaScript object.
</p>
</section>
<section>
<h3>Symmetry to CSS components</h3>
<p>
If you are using some CSS component architecture like <a href="https://css-tricks.com/bem-101/">BEM</a>
you will find a nice symmetry between your CSS components and Unpoly compilers:
</p>
<div class='columns'>
<div class='column'>
<pre><code class='nohighlight' data-noescape><b>app/assets/stylesheets/blocks</b>
 carousel.css
 head.css
 map.css
 screenshot.css
 tail.css</code></pre>
</div>
<div class='column'>
<pre><code class='nohighlight' data-noescape><b>app/assets/javascripts/compilers</b>
 carousel.js
 head.js
 map.js
 screenshot.js

</code></pre>
</div>
</div>
<p>
By sticking to this pattern you will always know where to find the CSS / JS that affects
your
<code class='blue'><div class='map'>...</div></code> element.
</p>
</section>
<section>
<h2>Response times</h2>
</section>
<section>
<h3>
<div class='subtle'>
Reponse times
</div>
<div class='line'>
How fast are SPAs?
</div>
</h3>
<p>
We want to approximate the snappiness of a AngularJS SPA
<br>
(since we're happy with those). How fast is an SPA?
</p>
<ul>
<li>
Most of our AngularJS interactions are making API requests
<br>
and are thus bound by server speed.
</li>
<li>
<div class='line'>
Rendering to JSON takes time, too.
</div>
<div class='subtle'>
60-300ms for index views in non-trivial app
</div>
</li>
<li>
<div class='line'>
Client-side rendering takes time, too.
</div>
</li>
<li>
<div class='line'>
Users do like the instantaneous feedback
</div>
<div class='subtle'>
(even if it just shows to an empty screen that is then populated over the wire)
</div>
</li>
</ul>
</section>
<section>
<h3>
<div class='subtle'>
Response times
</div>
<div class='line'>
Unpoly's approach
</div>
</h3>
<ul>
<li>
Provide instantaneous feedback to all user input
so interactions<br>appear faster than they really are
</li>
<li>Pick <u>all</u> the low-hanging fruit that's wasting 100s of milliseconds</li>
<li>Free up enough time budget that we can afford to render<br>full pages on the server</li>
<li>Use best practices for server performance</li>
<li>Provide options if all that is not enough</li>
</ul>
</section>
<section>
<h3>What you get out of the box</h3>
<ul>
<li>
We no longer parse and execute CSS, JavaScript and build the DOM on every request
<div class='subtle'>
makandra deck on Cards (140 ms), AMC frontend (360 ms)
</div>
</li>
<li>
Clicked links/forms get an <a href="https://unpoly.com/up-active"><code>.up-active</code></a> class while loading
<div class='subtle'>
Get into a habit of styling <code>.up-active</code> for instantaneous feedback<br>
Use throttling and Chrome's network tab
</div>
</li>
<li>
Links with an <a href="https://unpoly.com/up-instant"><code>[up-instant]</code></a> attribute load on <code>mousedown</code> instead of <code>click</code>
<div class='subtle'>
Saves ~70 ms with a mouse (<a href="http://instantclick.io/click-test" target="_blank">test yourself</a>)
<br>
Saves ~300 ms on unoptimized sites with touch device
<br>
Your Linux/Windows apps do that, too!
</div>
</li>
<li>
Links with <a href="https://unpoly.com/up-preload"><code>[up-preload]</code></a> attribute preload destination while hovering
<div class='subtle'>
Saves ~200-400 ms minus configured delay (<a href="http://instantclick.io/click-test" target="_blank">test yourself</a>)
</div>
</li>