ways to measure & boost performance of your react app

112
REACT PERFORMANCE HOW TO SPEED YOUR APP UP

Upload: kateryna-porshnieva

Post on 14-Jan-2017

50 views

Category:

Software


3 download

TRANSCRIPT

Page 1: Ways to measure & boost performance of your React app

REACT PERFORMANCE

HOW TO SPEED YOUR APP UP

Page 2: Ways to measure & boost performance of your React app

My name is Kateryna Porshnieva

live in Kiev, Ukraine

work as Front-End Developer & UI/UX designer at YouScan

teach React & Redux course in Ukraine

@krambertech

Page 3: Ways to measure & boost performance of your React app

PART 1:

WHAT MAKES APPS FEEL `FAST`

Page 4: Ways to measure & boost performance of your React app

‣Fast load speed

‣Fast user interactions

‣Smooth animations

Page 5: Ways to measure & boost performance of your React app

PART 2:

FIRST LOAD SPEED

Page 6: Ways to measure & boost performance of your React app

BUNDLE SIZE

Page 7: Ways to measure & boost performance of your React app

1. SET NODE_ENV TO `PRODUCTION`

Page 8: Ways to measure & boost performance of your React app
Page 9: Ways to measure & boost performance of your React app

2. TRANSFORM REACT CONSTANT ELEMENTS

Page 10: Ways to measure & boost performance of your React app
Page 11: Ways to measure & boost performance of your React app
Page 12: Ways to measure & boost performance of your React app

3. INLINE REACT ELEMENTS

Page 13: Ways to measure & boost performance of your React app
Page 14: Ways to measure & boost performance of your React app

4. REMOVE PROPTYPES

Page 15: Ways to measure & boost performance of your React app
Page 16: Ways to measure & boost performance of your React app

5. TRANSFORM PURE CLASS TO FUNCTION

Page 17: Ways to measure & boost performance of your React app
Page 18: Ways to measure & boost performance of your React app
Page 19: Ways to measure & boost performance of your React app

REACT-OPTIMIZE ❤

Page 20: Ways to measure & boost performance of your React app
Page 21: Ways to measure & boost performance of your React app

6. REMOVE UNUSED LOCALES FROM MOMENT.JS

Page 22: Ways to measure & boost performance of your React app
Page 23: Ways to measure & boost performance of your React app
Page 24: Ways to measure & boost performance of your React app

1.98 MB -> 1.24 MB

Page 25: Ways to measure & boost performance of your React app

PART 3:

PERFORMANT UPDATES

Page 26: Ways to measure & boost performance of your React app

- Everyone

“React is fast”

Page 27: Ways to measure & boost performance of your React app
Page 28: Ways to measure & boost performance of your React app
Page 29: Ways to measure & boost performance of your React app
Page 30: Ways to measure & boost performance of your React app
Page 31: Ways to measure & boost performance of your React app

VIRTUAL DOM

Page 32: Ways to measure & boost performance of your React app
Page 33: Ways to measure & boost performance of your React app
Page 34: Ways to measure & boost performance of your React app
Page 35: Ways to measure & boost performance of your React app
Page 36: Ways to measure & boost performance of your React app
Page 37: Ways to measure & boost performance of your React app
Page 38: Ways to measure & boost performance of your React app
Page 39: Ways to measure & boost performance of your React app
Page 40: Ways to measure & boost performance of your React app
Page 41: Ways to measure & boost performance of your React app

React re-renders the whole app on any state (data) change

Page 42: Ways to measure & boost performance of your React app

PART 4:

MEASURING PERFORMANCE

Page 43: Ways to measure & boost performance of your React app

CONSOLE.TIME

Page 44: Ways to measure & boost performance of your React app
Page 45: Ways to measure & boost performance of your React app

CHROME DEVTOOLS ELEMENTS PANE

Page 46: Ways to measure & boost performance of your React app
Page 47: Ways to measure & boost performance of your React app

REACT 15.4 +

CHROME DEVTOOLS TIMELINE

Page 48: Ways to measure & boost performance of your React app
Page 49: Ways to measure & boost performance of your React app

REACT-ADDONS-PERF

Page 50: Ways to measure & boost performance of your React app
Page 51: Ways to measure & boost performance of your React app

FPS-METER

Page 52: Ways to measure & boost performance of your React app
Page 53: Ways to measure & boost performance of your React app

REACT DEVTOOLS +

TRACE REACT UPDATES

Page 54: Ways to measure & boost performance of your React app
Page 55: Ways to measure & boost performance of your React app

PART 5:

OPTIMIZING PERFORMANCE

Page 56: Ways to measure & boost performance of your React app

SHOULDCOMPONENTUPDATE

Page 57: Ways to measure & boost performance of your React app
Page 58: Ways to measure & boost performance of your React app
Page 59: Ways to measure & boost performance of your React app

PURE COMPONENTS

Page 60: Ways to measure & boost performance of your React app
Page 61: Ways to measure & boost performance of your React app
Page 62: Ways to measure & boost performance of your React app
Page 63: Ways to measure & boost performance of your React app
Page 64: Ways to measure & boost performance of your React app

react v15.3 and higher

Page 65: Ways to measure & boost performance of your React app

OPTIMIZING FOR PURE COMPONENTS

Page 66: Ways to measure & boost performance of your React app

1. FUNCTION.BIND / ARROW FUNCTIONS

Page 67: Ways to measure & boost performance of your React app
Page 68: Ways to measure & boost performance of your React app
Page 69: Ways to measure & boost performance of your React app
Page 70: Ways to measure & boost performance of your React app
Page 71: Ways to measure & boost performance of your React app
Page 72: Ways to measure & boost performance of your React app
Page 73: Ways to measure & boost performance of your React app

2. ARRAYS / OBJECTS CREATION

Page 74: Ways to measure & boost performance of your React app
Page 75: Ways to measure & boost performance of your React app
Page 76: Ways to measure & boost performance of your React app
Page 77: Ways to measure & boost performance of your React app
Page 78: Ways to measure & boost performance of your React app
Page 79: Ways to measure & boost performance of your React app
Page 80: Ways to measure & boost performance of your React app

3. MODIFICATION BY REFERENCE

Page 81: Ways to measure & boost performance of your React app
Page 82: Ways to measure & boost performance of your React app
Page 83: Ways to measure & boost performance of your React app
Page 84: Ways to measure & boost performance of your React app
Page 85: Ways to measure & boost performance of your React app

IMMUTABLE.JS

Page 86: Ways to measure & boost performance of your React app

PART 7:

REDUX PERFORMANCE

Page 87: Ways to measure & boost performance of your React app

CONNECT COMPONENTS TO STATE AT LOWER LEVEL

Page 88: Ways to measure & boost performance of your React app
Page 89: Ways to measure & boost performance of your React app
Page 90: Ways to measure & boost performance of your React app
Page 91: Ways to measure & boost performance of your React app
Page 92: Ways to measure & boost performance of your React app
Page 93: Ways to measure & boost performance of your React app

MEMOIZATION

Page 94: Ways to measure & boost performance of your React app
Page 95: Ways to measure & boost performance of your React app
Page 96: Ways to measure & boost performance of your React app
Page 97: Ways to measure & boost performance of your React app
Page 98: Ways to measure & boost performance of your React app

PART 8:

PRETEND WORKING FAST

Page 99: Ways to measure & boost performance of your React app

SPINNERS / PROGRESS BARS

Page 100: Ways to measure & boost performance of your React app
Page 101: Ways to measure & boost performance of your React app

<1s 1-4s >4s

Nothing Spinner Progress bar

Page 102: Ways to measure & boost performance of your React app

OPTIMISTIC UPDATES

Page 103: Ways to measure & boost performance of your React app

Image credit: https://uxplanet.org/optimistic-1000-34d9eefe4c05

Page 104: Ways to measure & boost performance of your React app

Image credit: https://uxplanet.org/optimistic-1000-34d9eefe4c05

Page 105: Ways to measure & boost performance of your React app

Image credit: https://uxplanet.org/optimistic-1000-34d9eefe4c05

Page 106: Ways to measure & boost performance of your React app

VIRTUAL SCROLLING

Page 107: Ways to measure & boost performance of your React app

Image credit: https://medium.com/outsystems-engineering/virtualizing-the-virtual-dom-pushing-react-further-d76a16e5f209

Page 108: Ways to measure & boost performance of your React app

Image credit: https://bvaughn.github.io/connect-tech-2016/#/8/4

Page 109: Ways to measure & boost performance of your React app
Page 110: Ways to measure & boost performance of your React app

CACHING

Page 111: Ways to measure & boost performance of your React app

PART 9:

WHEN TO OPTIMIZE

Page 112: Ways to measure & boost performance of your React app

FIN.