-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
1852 lines (1698 loc) · 55.8 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 charset="utf-8">
<title>High Perf JS CSS</title>
<meta name="description" content="An intermediate to advanced tips and tricks for High Performance JavaScript and CSS">
<meta name="author" content="Md Khan">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/custom.css" id="theme">
<!-- <link rel="stylesheet" type="text/css" href="css/print/pdf.css"> -->
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<style type="text/css">
.noUppercase
{
text-transform: none !important;
}
.fullScreenImage
{
width: 100%;
height: 90%;
}
.reveal h1.upholdHeader{
margin-top: -50px;
margin-left: -15%;
width: 130%;
}
.mediumFont{
font-size: 2em;
}
.reveal code.largeCode {
max-height: 600px;
}
.greenBold{
color: green;
font-weight: bold !important;
}
.lineThrough{
text-decoration: line-through;
}
.redBoldText{
font-weight: bold;
color: red;
}
.purpleBold{
font-weight: bold;
color:purple;
}
</style>
<!-- If the query includes 'print-pdf', use the PDF print sheet -->
<script>
document.write( '<link rel="stylesheet" href="css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
</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">
<!-- start of intro -->
<section>
<h1>High Performance JS & CSS</h1>
<br/>
<h2><a href="http://bit.ly/1gx0FRU">http://bit.ly/1gx0FRU</a> </h2>
<br/>
<p>
<a href="http://jhankarmahbub.com">MD Khan</a> / <a href="http://twitter.com/mdkhan005">@mdkhan005</a>
</p>
</section>
<section>
<img src="images/goingWork.jpg" alt="">
<a href="http://bit.ly/1gx0FRU">http://bit.ly/1gx0FRU</a>
</section>
<section>
<section>
<h1 class="upholdHeader">Quick Performance!</h1>
<img class="fullScreenImage" src="images/success.jpg">
</section>
<section>
<img src="images/redBull.jpg" alt="" class="fullScreenImage">
</section>
<section>
<img src="images/redBullWings.jpeg" alt="" class="fullScreenImage">
</section>
<section>
<img class="fullScreenImage" src="images/developerSecret.jpg">
</section>
<section>
<img class="fullScreenImage" src="images/coffeePot.jpg">
</section>
<section>
<img class="fullScreenImage" src="images/pizzaSlice.jpg">
</section>
<section>
<img class="fullScreenImage" src="images/badBoss.jpg">
</section>
<section><img src="images/manageDeveloper.jpg" alt="" class="fullScreenImage"></section>
</section>
<section>
<section>
<h1 class ="noUppercase">How do we develop a app?</h1>
</section>
<section>
<img class="fullScreenImage" src="images/bike.jpg">
</section>
<section>
<img class="fullScreenImage" src="images/fancyBike.jpg">
</section>
<section>
<img class="fullScreenImage" src="images/emptyBike.jpg">
</section>
<section>
<img class="fullScreenImage" src="images/bikeHack.jpeg">
</section>
<section>
<img class="fullScreenImage" src="images/bikeCow.jpg">
</section>
<section>
<img class="fullScreenImage" src="images/bikeBrick.jpg">
</section>
<section>
<img class="fullScreenImage" src="images/bikeGreen.jpg">
</section>
<section>
<img class="fullScreenImage" src="images/bikeDesi.jpg">
</section>
<section>
<img class="fullScreenImage" src="images/bikeFullLoad.jpg">
</section>
<section>
<img class="fullScreenImage" src="images/fancyBike.jpg">
</section>
</section>
<!-- End of Intro -->
<section>
<section>
<h1>Performance matters ! ! ! !</h1>
<h4>Every milisecond counts</h4>
</section>
<section>
<img src="images/googleClassic.jpg" alt="">
</section>
<section>
<img src="images/snakeDodge.jpg" alt="">
</section>
<section>
<h1 class="noUppercase upholdHeader" > Optimization :- </h1>
<ul class="mediumFont">
<li class="fragment" >Subjective</li>
<li class="fragment" >Could be Expensive</li>
<li class="fragment" >Not Always Valid</li>
<li class="fragment" >Don't Guess, Measure it</li>
</ul>
</section>
<section>
<h1 class="noUppercase" > Expectations !!!</h1>
<ul>
<li class="fragment" >Browser</li>
<li class="fragment" >CSS</li>
<li class="fragment" >JavaScript</li>
<li class="fragment" >Debug</li>
</ul>
</section>
</section>
<!-- Start of How Browser Works -->
<section>
<section>
<h2 class="upholdHeader">How Browser Works??</h2>
<img class="fullScreenImage" src="images/browser.jpg">
</section>
<section>
<h1 >Browser</h1>
<ul>
<li>Versions</li>
<li>Bugs</li>
<li>Changing</li>
</ul>
</section>
<!-- <section>
<img class="fullScreenImage" src="http://1.media.collegehumor.cvcdn.com/78/58/4fe20a0003ba1c49375468f9ac47950e-which-one-of-these-is-not-a-web-browser.jpg">
</section> -->
<section>
<h1 class="upholdHeader">Why learn about Browser?</h1>
<br/>
<ul>
<li class="fragment" >Play Ground</li>
<li class="fragment" >Geek / Freak </li>
<li class="fragment">Don't forget Devices</li>
</ul>
</section>
<section>
<img class="fullScreenImage" src="images/lifeOfARequest.png" alt="">
<a href="http://www.w3.org/TR/navigation-timing/">W3.org: navigation-timing</a>
</section>
<section>
<img class="fullScreenImage" src="images/lifeOfARequestParts.png" alt="">
</section>
<section>
<h2>Your Html</h2>
<pre><code contenteditable>
1. <html>
2. <body>
3. <p>
4. Hello World
5. </p>
6. <div>
7. <img src="example.png"/>
8. </div>
9. </body>
10. </html>
</code></pre>
<a href="http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/">How Browser Works</a>
</section>
<section>
<img class="fullScreenImage" src="images/domTreeWithHTML.png">
</section>
<section>
<h1 class="upholdHeader">Validate Html</h1>
<br/>
<p>Don’t Just Wrap a DIV Around It</p>
<br/>
<h3>Make HTML Parsing Easier</h3>
<br/>
<br/>
<a href="http://net.tutsplus.com/tutorials/html-css-techniques/30-css-best-practices-for-beginners/">30 CSS Best Practices</a>
</section>
<section>
<h2>Style</h2>
<pre><code contenteditable>
p,div{
margin-top:3px;
}
.error {
color:red;
}
</code></pre>
</section>
<section>
<img class="fullScreenImage" src="images/parsingCSS.png">
</section>
<section>
<h1 class="noUppercase">Render Tree</h1>
<img src="images/renderTree.png">
</section>
<section>
<h1 class="upholdHeader">So far</h1>
<img class="fullScreenImage" src="images/uptoRenderTree.png">
</section>
<section>
<h1 class="upholdHeader">Layout</h1>
<img class="fullScreenImage" src="images/layout.png">
<a href="http://en.wikipedia.org/wiki/Comparison_of_layout_engines_(Cascading_Style_Sheets)">CSS Layout Engines</a>
</section>
<section>
<h1 class="noUppercase">Paint</h1>
<img src="images/painting.png">
</section>
</section>
<section>
<section>
<h1>Need to Change</h1>
</section>
<section>
<h1 class="upholdHeader" >Avoid Change</h1>
<ul>
<li class="fragment">Minimum change</li>
<li class="fragment">Don't change Layout</li>
<li class="fragment">Change Background Color</li>
<li class="fragment">Change Text Color</li>
<li class="fragment">Visibility: hidden</li>
</ul>
</section>
<section>
<h1 class="upholdHeader">Re paint</h1>
<img class="fullScreenImage" src="images/repaint.png">
</section>
<section>
<h1 class="upholdHeader" >More Changes => More Work</h1>
<ul>
<li class="fragment">Change Layout</li>
<li class="fragment">Change Width / Height</li>
<li class="fragment">Change Font</li>
<li class="fragment">Move DOM Node</li>
<li class="fragment">Resize Window</li>
<li class="fragment">Display: none</li>
</ul>
</section>
<section>
<h1 class="upholdHeader">Re Flow</h1>
<img class="fullScreenImage" src="images/reFlow.png">
</section>
<section>
<h1 class="upholdHeader">Try to Avoid</h1>
<h1 style="color:purple;"> Re-flow</h1>
<p class="fragment">Use DOM DocumentFragment </p>
<h2 class="fragment">Clone the DOM</h2>
<br/>
<a href="http://www.html5rocks.com/en/tutorials/speed/high-performance-animations/">Styles affect paint and layout</a>
<br/>
<a href="http://ejohn.org/blog/dom-documentfragments/">John Resig: DOM DocumentFragment</a>
<br/>
<a href="https://developer.mozilla.org/en-US/docs/Web/API/document.createDocumentFragment">MDN: DocumentFragment</a>
<br/>
<a href="http://www.phpied.com/rendering-repaint-reflowrelayout-restyle/">Re flow Layout</a>
<br/>
<a href="https://github.com/stevekwan/best-practices/blob/master/javascript/best-practices.md">JS best practices</a>
<br/>
<a href="http://jonraasch.com/blog/10-javascript-performance-boosting-tips-from-nicholas-zakas">Nicholas Zakas: 10 JS Performance Boosting</a>
</section>
</section>
<!-- End of Browser -->
<!-- start of CSS -->
<section>
<section>
<h1 class="upholdHeader">Lets Talk about CSS</h1>
</section>
<section>
<h1 class="upholdHeader">CSS Selectors</h1>
<img style="width:800px; height:700px;" src="images/css.jpg">
</section>
<section>
<h1 class="upholdHeader">ID</h1>
<pre><code contenteditable>
1. <style>
2. #myFirstTODO
3. {
4. color:red;
5. }
6. </style>
7.
8. <div>
9. <p id="myFirstTODO"> <span style="color:red;">have to shower </span></p>
10. <p> have to shave</p>
11. <p> have to cut hair</p>
12. <p> buy perfume</p>
13. <p> at least buy t shirt</p>
14. </div>
</code></pre>
</section>
<section>
<h1 class="upholdHeader">Class</h1>
<pre><code contenteditable>
1. <style>
2. .greenBold
3. {
4. color: green;
5. font-weight:bold;
6. }
7. </style>
8.
9. <div>
10. <p> have to shower</p>
11. <p class="greenBold"> <span class="greenBold">have to shave</span></p>
12. <p class="greenBold"> <span class="greenBold">have to cut hair</span></p>
13. <p> buy perfume</p>
14. <p> at least buy t shirt</p>
15. </div>
</code></pre>
</section>
<section>
<h2 class="upholdHeader">Immediate Children</h2>
<pre><code class="largeCode" contenteditable>
1. <style>
2. li > ul
3. {
4. color: green;
5. font-weight: bold;
6. }
7. </style>
8.
9. <div>
10. <ul>
11. <li> List Item
12. <ul>
13. <li><span class="greenBold"> Child</span> </li>
14. </ul>
15. </li>
16. <li> List Item </li>
17. <li> List Item </li>
18. <li> List Item </li>
19. </ul>
20. </div> </code></pre>
</section>
<section>
<h1 class="upholdHeader">Descendent</h1>
<pre><code contenteditable>
#myTODO p
{
color: green;
font-weight: bold;
}
</code></pre>
</section>
<section>
<h1 class="upholdHeader">Fancy Selectors</h1>
<br/>
<br/>
<h3 class = "fragment">div + p { /*Adjacent*/ }</h3>
<h3 class = "fragment">div ~ p { /*Sibling*/ }</h3>
<h4 class = "fragment">input[type="checkbox"] { /*Attribute*/}</h4>
<h3 class = "fragment">p:first-child { /*pseudo*/}</h3>
<br/>
<br/>
<a href="http://net.tutsplus.com/tutorials/html-css-techniques/the-30-css-selectors-you-must-memorize/">Advanced CSS Selectors</a>
</section>
<section>
<h1 class="upholdHeader" style="color:green;">You can</h1>
<h1 class="upholdHeader fragment" style="color:red; margin-top: 0px">Doesn't mean you should</h1>
<br/>
<br/>
<a href="http://www.youtube.com/watch?v=ldx4ZFxMEeo"> Better Quality CSS</a>
<br/>
<a href="http://www.stubbornella.org/content/2011/04/28/our-best-practices-are-killing-us/">Best Practices are killing us</a>
<br/>
<a href="http://stackoverflow.com/questions/1230636/css-optimization-element-id-vs-class">CSS Optimization</a>
</section>
</section>
<section>
<section>
<h1 class="upholdHeader">Render Speed</h1>
<img src="images/ambulence.jpg">
</section>
<section>
<br/>
<h3>ID - #myID</h3>
<br/>
<h3 class = "fragment">Class – .myClass</h3>
<br/>
<h3 class = "fragment">Tag – div</h3>
<br/>
<h3 class = "fragment">Sibling – div + p, div ~ p</h3>
<br/>
<h3 class = "fragment">Child – div > p</h3>
<br/>
</section>
<section>
<br/>
<h3>Descendant – div p</h3>
<br/>
<h3 class = "fragment">Universal – div *</h3>
<br/>
<h4 class = "fragment">Attribute – input[type="checkbox"]</h4>
<br/>
<h3 class = "fragment">Pseudo – p:first-child</h3>
<br/>
<br/>
<a href="http://realityonweb.com/cascading-style-sheet-css/performance-improvement-by-writing-efficient-css-selector/">Efficient CSS Selector</a>
<br/>
<a href="http://www.youtube.com/watch?v=a2_6bGNZ7bA">Faster HTML and CSS</a>
</section>
<section>
<h3 class="upholdHeader">This doesn't mean everything should be ID</h3>
<br/>
<h3 class = "fragment">ID and Class: Almost Similar</h3>
<br/>
<h3 class = "fragment">DRY, Readable & Maintainable</h3>
<br/>
<h1 class = "fragment" style="color:purple;">Fast</h1>
<br/>
<a href="http://css-tricks.com/the-difference-between-id-and-class/"> Difference between ID and Class</a>
</section>
</section>
<section>
<section>
<h1 class="upholdHeader">CSS Try to Avoid</h1>
<br/>
<br/>
<a href="https://developers.google.com/speed/docs/best-practices/rendering">Rendering Best practices</a>
<br/>
<a href="https://developers.google.com/speed/docs/best-practices/rendering">Google: Optimize Browser Rendering</a>
</section>
<section>
<h3 class="lineThrough">Universal Key Selector</h3>
<pre><code contenteditable>
body * {
color:#365277;
}
.hide-scrollbars * {
font-size: 16px;
}
</code></pre>
</section>
<section>
<h3 class="lineThrough">When you can't read easily. Same to Browser</h3>
<pre><code contenteditable>
#myDiv ul li button
{
width:200px;
}
#myDiv ul li:nth-child(2) li:nth-child(7) > a
{
color:red;
}
</code></pre>
</section>
<section>
<h3 class = "noUppercase">Use class</h3>
<pre><code contenteditable>
.btnMedium
{
width:200px;
}
.myClass
{
color:red;
}
</code></pre>
</section>
<section>
<h3 class = "noUppercase">Don't Repeat</h3>
<pre><code contenteditable>
.upTrend
{
background-image:url('upGreen.jpg');
background-repeat:no-repeat;
background-position: center center;
padding-left:20px;
}
.downTrend
{
background-image:url('downRed.jpg');
background-repeat:no-repeat;
background-position: center center;
padding-left:20px;
}
</code></pre>
</section>
<section>
<h3 class = "noUppercase">Still Repeating</h3>
<pre><code contenteditable>
.upTrend
{
background-image:url('upGreen.jpg') center center no-repeat;
padding-left:20px;
}
.downTrend
{
background-image:url('downRed.jpg') center center no-repeat;
padding-left:20px;
}
</code></pre>
</section>
<section>
<h3 class="noUppercase">Combine Common Styles</h3>
<pre><code class="largeCode" contenteditable>
.upTrend
{
background-image:url('upGreen.jpg');
}
.downTrend
{
background-image:url('downRed.jpg');
}
.upTrend, .downTrend
{
background-repeat:no-repeat;
background-position: center center;
padding-left:20px;
}
</code></pre>
<a href="http://www.vanseodesign.com/css/dry-principles/">DRYer CSS</a>
</section>
<section>
<h3 class="lineThrough">Be as specific as possible.</h3>
<pre><code contenteditable>
ul li a
{
/* My awesome anchor */
}
* html #atticPromo ul li a
{
/* My awesome rules */
}
</code></pre>
</section>
<section>
<h3 class="lineThrough">Redundant selectors</h3>
<pre><code contenteditable>
ul #top_blue_nav
{
...
}
form #UserLogin
{
...
}
</code></pre>
</section>
<!--
<section>
<h1> CSS expressions</h1>
</section>
<section>
<pre><code contenteditable>
//get from google best practices link before
</code></pre>
</section>
-->
<section>
<h3 class="lineThrough">Check again your child selectors</h3>
<pre><code contenteditable>
//don't
treeitem[IsImapServer="true"] > treerow > .tree-folderpane-icon
{
...
}
//do
.tree-folderpane-icon[IsImapServer="true"]
{
...
}
</code></pre>
<br/>
<a href="https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Writing_efficient_CSS?redirectlocale=en-US&redirectslug=CSS%2FWriting_Efficient_CSS">Mozilla Rendering Guides</a>
</section>
</section>
<section>
<section>
<h1 class="upholdHeader">How CSS Selectors are Matched</h1>
</section>
<section>
<pre><code class="largeCode" contenteditable>
1. <html>
2. <head>
3. //head omitted due to lack of brain
4. </head>
5. <body>
6. <header>
7. <h1>My Awesome title</h1>
8. </header>
9. <nav>
10. <ol>
11. <li><a href="#">StackOverflow</a></li>
12. <li><a href="#">StackOverflow</a></li>
13. </ol>
14. </nav>
15. <section>
16. <div>
17. <ul>
18. <li><a href="#">StackOverflow</a></li>
19. <li><a href="#">StackOverflow</a></li>
20. </ul>
21. </div>
22. </section>
23. </body>
24.</html>
</code></pre>
</section>
<section>
<img class="fullScreenImage" src="images/roughDOMTreeWithHTML2.png">
</section>
<section>
<h1 class="upholdHeader">li { color: red; }</h1>
<ul>
<!-- <li class="fragment">Root level</li> -->
<li class="fragment">Run only once</li>
</ul>
</section>
<section>
<h1 class="upholdHeader">nav a {color:green;}</h1>
</section>
<section>
<h2 class="upholdHeader">nav a {color:green;}</h2>
<img class="fullScreenImage" src="images/rightToLeft1.png">
</section>
<section>
<h2 class="upholdHeader">nav a {color:green;}</h2>
<img class="fullScreenImage" src="images/rightToLeft2.png">
</section>
<section>
<h2 class="upholdHeader">nav a {color:green;}</h2>
<img class="fullScreenImage" src="images/rightToLeft3.png">
</section>
<section>
<img class="fullScreenImage" src="images/htmlTree.png">
</section>
<section>
<h2 class="upholdHeader">Browser Evaluates Selectors?</h2>
<h1 style="color:red;" class="fragment">Right to Left</h1>
<h1 style="color:gray;"><=</h1>
<br/><br/><br/><br/>
<a href="http://islovely.co/blog/understanding-css-hierarchy-matching/">CSS hierarchy matching</a>
<br/>
<a href="http://islovely.co/blog/writing-high-performance-css/">High Performance CSS</a>
<br/>
<a href="http://www.eddiewelker.com/2011/04/06/high-performance-css-code-design/">CSS Code Design</a>
</section>
</section>
<section>
<section>
<h1 class="upholdHeader">CSS Specificity</h1>
<br/>
<br/>
<pre><code contenteditable>
/* Take Advantage of CSS specificity */
/* class, id, inline, !important */
</code></pre>
<br/>
<a href="http://www.standardista.com/css3/css-specificity/">Estelle Weyl: CSS SpeciFISHity</a>
<br/>
<a href="http://css-tricks.com/specifics-on-css-specificity/">CSS-Tricks: CSS Specificity</a>
<br/>
<a href="http://www.youtube.com/watch?v=SLC83iesr60">Understanding CSS</a>
<br/>
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity">MDN: Specificity</a>
<br/>
<a href="http://specificity.keegan.st/">Specificity calculator</a>
<br/>
<a href="http://diythemes.com/thesis/css-specificity-thesis/">Power of Specificity</a>
<br/>
<a href="http://coding.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/">CSS Specificity: Things you should know</a>
</section>
<section>
<h1>Unused CSS</h1>
<a href="http://unused-css.com/">Detect Unused Css</a><br/>
</section>
</section>
<!-- End of CSS -->
<!-- Start of JS Best Practice -->
<section>
<section>
<h1>JavaScript</h1>
</section>
<section>
<img src="images/longRun3.jpg" alt="">
<img class="fragment" src="images/longRun.png" alt="">
</section>
<section>
<h1 class="upholdHeader">JS try to Avoid</h1>
</section>
<section>
<h2 class="lineThrough">Access Same Variable</h2>
<pre><code contenteditable>
var blah = document.getElementById('myID');
var blah2 = document.getElementById('myID2');
var blah3 = document.getElementById('myID3');
var blah = document.getElementById('myID'),
blah2 = document.getElementById('myID2'),
blah3 = document.getElementById('myID3');
</code></pre>
</section>
<section>
<h2>Localize variable</h2>
<pre><code contenteditable>
var doc = document,
blah = doc.getElementById('myID'),
blah2 = doc.getElementById('myID2'),
blah3 = doc.getElementById('myID3');
</code></pre>
</section>
<section>
<h2 class="lineThrough">My For Loop</h2>
<pre><code contenteditable>
for(var i = 0; i < someArray.length; i++) {
var container = document.getElementById('container');
container.innerHtml += 'my number: ' + i;
console.log(i);
}
</code></pre>
</section>
<section>
<h2>Cache outside of loop</h2>
<pre><code contenteditable>
var container = document.getElementById('container');
for(var i = 0; i < someArray.length; i++) {
container.innerHtml += 'my number: ' + i;
console.log(i);
}
</code></pre>
</section>
<section>
<h2>Little More!!!</h2>
<pre><code contenteditable>
var container = document.getElementById('container');
for(var i = 0, len = someArray.length; i < len; i++) {
container.innerHtml += 'my number: ' + i;
console.log(i);
}
</code></pre>
</section>
<section>
<h2>Even Better</h2>
<pre><code>
var i,
length = 100;
for ( i = 0; i < length; i++ ) {
// statements
}
// Or...
var i = 0,
length = 100;
for ( ; i < length; i++ ) {
// statements
}
</code></pre>
<a href="https://github.com/rwaldron/idiomatic.js#table-of-contents">Idiomatic JS</a>
</section>
<section>
<h2 class="upholdHeader">Use === than ==</h2>
<pre><code contenteditable>
0 == ''; // true
0 === false; //false
</code></pre>
<pre class="fragment"><code contenteditable>
if (( x === null) || (x === undefined)){ ... }
if(x == null) { ... }
</code></pre>
<p class="fragment"> When you don't actually know whether they are same type</p>
<pre class="fragment"><code contenteditable>
typeof thing == 'function'; //always be string
myArray.length == 0; //will always be number
mySting.indexOf('x') == 0;
</code></pre>
<a href="http://www.youtube.com/watch?v=MFtijdklZDo">bReaK aLL thE RuleZ</a>
</section>
<section>
<h2>Initialize if Undefined</h2>
<pre><code contenteditable>
if ( !MyNamespace ) {
var MyNamespace = { };
}
//or
var myNamespace = myNamespace || {};
//or http://jsperf.com/conditional-assignment
// myNamespace || ( myNamespace = {} );
//or
if ( typeof MyNamespace == ’undefined’ ) {
var MyNamespace = { };
}
</code></pre>
<a href="http://developer.nokia.com/Community/Wiki/JavaScript_Performance_Best_Practices">Nokia: JS Best Practice</a>
</section>
</section>
<section>
<section>
<h1 class="upholdHeader">JavaScript: String</h1>
</section>
<section>
<img src="images/concat.jpg" alt="">
</section>
<section>
<h2 class="lineThrough">String Concatenation</h2>
<pre><code contenteditable>
var tinyMessage = 'Trust me, i started one line' +
'Designer told me he wants little more' +
'I added little more' +
'Manager said, this is not enough' +
"He didn't said what to add" +
'Just said add' +
"I didn't know what to add" +
'So i added a slice of pizza' +
'Client said this is stupid' +
'Manager said, client is right';
</code></pre>
<a href="https://developers.google.com/speed/articles/optimizing-javascript"> Optimize JavaScript </a>
</section>
<section>
<h2>[ ].join(' ')</h2>
<pre><code contenteditable>
var tinyMessage = ['Trust me, i started one line',
'Designer told me he wants little more',
'I added little more',
'Manager said, this is not enough',
"He didn't said what to add",
'Just said add',
"I didn't know what to add",
'So i added a slice of pizza',
'Client said this is stupid',
'Manager said, client is right'].join(' ');
</code></pre>
<a href="http://jsperf.com/array-join-vs-string-connect">array-join-vs-string-connect</a>
<br/>
<a href="http://stackoverflow.com/questions/7299010/why-is-string-concatenation-faster-than-aray-join">Why is string concatenation faster than array join</a>
<br/>
<a href="http://stackoverflow.com/questions/9538678/fastest-way-to-build-this-string">fastest-way-to-build-this-string</a>
</section>
<!-- <section>
<h2>Insted</h2>
<pre><code contenteditable>
var fibonacciStr = 'First 20 Fibonacci Numbers';
for (var i = 0; i < 20; i++) {
fibonacciStr += i + ' = ' + fibonacci(i) + ' ';
}
</code></pre>
</section> -->
<section>
<h2>Your Own String Builder</h2>
<pre><code contenteditable>
var strBuilder = ['First 20 fibonacci numbers:'];
for (var i = 0; i < 20; i++) {
strBuilder.push( i, '=', fibonacci(i));
}
var fibonacciStr = strBuilder.join(' ');
</code></pre>
</section>
<!-- commented out prototype and set time out stuff -->
<!--
<section>
<h2>Don't</h2>
<pre><code contenteditable>
baz.Bar = function() {
// constructor body
this.foo = function() {
// method body
};
}
</code></pre>
</section>
<section>