Slide 1

Slide 1 text

Performance in by Yuya Saito / Rich Media CSS 2014.09.09 @ hikalab

Slide 2

Slide 2 text

UX Engineer @ Yuya Saito

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

#perfmatters

Slide 6

Slide 6 text

Rendering Performance on CSS

Slide 7

Slide 7 text

Jank: What is it?

Slide 8

Slide 8 text

εΫϩʔϧͷࡍʹͳΜ͔Ҿ͔͔ͬΔ Ξχϝʔγϣϯ͕ΧΫΧΫͯ͠͠·͏

Slide 9

Slide 9 text

Parallax!!

Slide 10

Slide 10 text

Frame = 16.666666666666666ms 60FPS

Slide 11

Slide 11 text

How Browser Render Pixel

Slide 12

Slide 12 text

Recalculate Style

Slide 13

Slide 13 text

ͦΕ΄ͲେมͳλεΫͰ͸ͳ͍ ϒϥ΢βʹͱͬͯ

Slide 14

Slide 14 text

Hello World p { font-weight: bold; } span { display: none; } CSSOM CSS Object Model

Slide 15

Slide 15 text

Layout

Slide 16

Slide 16 text

গʑ໽հͳ΋ͷ ϒϥ΢βʹͱͬͯ

Slide 17

Slide 17 text

DOM + CSSOM = Render Tree

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Paint

Slide 20

Slide 20 text

࠷΋ෛՙ͕͔͔Δϓϩηε ϒϥ΢βʹͱͬͯ

Slide 21

Slide 21 text

1>

Slide 22

Slide 22 text

Layout Paint

Slide 23

Slide 23 text

Composite

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Ұ୴ফͯ͠ɺࠨʹ10ηϯνͣΒͯ͠ॻ͖௚͢

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

GPU Graphical Processing Unit

Slide 29

Slide 29 text

Tools, Not Rules

Slide 30

Slide 30 text

“ For the most part we’ll be trying to get to 60fps in our work, and that normally means understanding what the browser’s doing and optimizing for it. — Paul Lewis

Slide 31

Slide 31 text

“ Tools, Not Rules — Paul Lewis

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

chrome://flags/#enable-devtools-experiments

Slide 35

Slide 35 text

“ You can't optimize what you can't measure. — Anonymous

Slide 36

Slide 36 text

Paint is Very Expensive

Slide 37

Slide 37 text

େ͖ͳΤϦΞͷϨΠΞ΢τɺελΠϧແޮԽ

Slide 39

Slide 39 text

Slide 40

Slide 40 text

How to solve it? ճආ

Slide 42

Slide 42 text

Slide 43

Slide 43 text

How to measure it? ܭଌ

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

Layout Thrashing

Slide 47

Slide 47 text

// Read var h1 = element1.clientHeight; ! // Write (invalidates layout) element1.style.height = (h1 * 2) + 'px'; ! // Read (triggers layout) var h2 = element2.clientHeight; ! // Write (invalidates layout) element2.style.height = (h2 * 2) + 'px'; ! // Read (triggers layout) var h3 = element3.clientHeight; ! // Write (invalidates layout) element3.style.height = (h3 * 2) + 'px';

Slide 48

Slide 48 text

How to measure it? ܭଌ

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

Forced Synchronous Layout

Slide 51

Slide 51 text

How to solve it? ճආ

Slide 52

Slide 52 text

// Read var h1 = element1.clientHeight; var h2 = element2.clientHeight; var h3 = element3.clientHeight; ! // Write (invalidates layout) element1.style.height = (h1 * 2) + 'px'; element2.style.height = (h2 * 2) + 'px'; element3.style.height = (h3 * 2) + 'px';

Slide 53

Slide 53 text

by Wilson Page git.io/KdTJYw fastdom

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

ϨΠΞ΢τɾϓϩύςΟͷΞχϝʔγϣϯ

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

How to measure it? ܭଌ

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

How to solve it? ճආ

Slide 61

Slide 61 text

www.html5rocks.com/en/tutorials/speed/high-performance-animations

Slide 62

Slide 62 text

-webkit-transform: translateZ(0);

Slide 63

Slide 63 text

will-change: animateable-feature

Slide 64

Slide 64 text

by Sara Soueidan bit.ly/WyKbT7 Everything You Need to Know About the CSS will-change Property

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

-webkit-transform: translateZ(0);

Slide 67

Slide 67 text

will-change: left, top;

Slide 68

Slide 68 text

by Paul Lewis csstriggers.com CSS TRIGGERS...

Slide 69

Slide 69 text

by Joel Besada bouncejs.com Bounce.js

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

by Julian Shapiro julian.com/research/velocity Velocity.js

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

Paint Storms

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

Changing visual properties of an element will trigger a paint.

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

৭Λมߋ

Slide 78

Slide 78 text

Paint!?

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

device-pixel-ratio = 1

Slide 82

Slide 82 text

positionFixed͕ͳ͍

Slide 83

Slide 83 text

How to measure it? ܭଌ

Slide 84

Slide 84 text

Show paint rectangles

Slide 85

Slide 85 text

No content

Slide 86

Slide 86 text

Experiments: Paint Profiler

Slide 87

Slide 87 text

No content

Slide 88

Slide 88 text

No content

Slide 89

Slide 89 text

How to solve it? ճආ

Slide 90

Slide 90 text

Don't Paint

Slide 91

Slide 91 text

www.html5rocks.com/en/tutorials/speed/high-performance-animations

Slide 92

Slide 92 text

-webkit-transform: translateZ(0); position: fixed;

Slide 93

Slide 93 text

ʰߴՁͳʱϖΠϯτ

Slide 94

Slide 94 text

box-shadow border-radius gradient

Slide 95

Slide 95 text

Resize Images

Slide 96

Slide 96 text

Paint affects not only Animation but also Scrolling

Slide 97

Slide 97 text

How to measure it? ܭଌ

Slide 98

Slide 98 text

No content

Slide 99

Slide 99 text

No content

Slide 100

Slide 100 text

Image Resize is missing?

Slide 101

Slide 101 text

How to solve it? ճආ

Slide 102

Slide 102 text

No content

Slide 103

Slide 103 text

CTRL + H

Slide 104

Slide 104 text

Images in Performance

Slide 105

Slide 105 text

Images are 1MB in 1.7MB

Slide 106

Slide 106 text

ߴղ૾౓σΟεϓϨΠ

Slide 107

Slide 107 text

by RICG The picture Element picture.responsiveimages.org

Slide 108

Slide 108 text

by Andreas Bovens bit.ly/1wdgML0 Responsive Images: Use Cases and Documented Code Snippets to Get You Started

Slide 109

Slide 109 text

In Closing

Slide 110

Slide 110 text

“ To me, performance is a feature […]. I think there’s also a lesson to be learned here about the competitive landscape of the public internet, where there are two kinds of websites: the quick and the dead. — Jeff Atwood, Coding Horror

Slide 111

Slide 111 text

When: The Hardest Question

Slide 112

Slide 112 text

Thank You! @cssradar