Slide 1

Slide 1 text

OPTIMIZATION AND PERFORMANCE ANALYSIS OF JAVASCRIPT APPLICATIONS JÉSSICA FÉLIX (@JESSILYNEH)

Slide 2

Slide 2 text

LIFECYCLE OF A JAVASCRIPT APPLICATION @jessilyneh

Slide 3

Slide 3 text

Lifecycle of a JavaScript application @jessilyneh Loading the JavaScript application source code

Slide 4

Slide 4 text

@jessilyneh

Slide 5

Slide 5 text

Lifecycle of a JavaScript application @jessilyneh Loading the JavaScript application source code Analyzing the source code

Slide 6

Slide 6 text

@jessilyneh

Slide 7

Slide 7 text

@jessilyneh AST (Abstract Syntax Tree)

Slide 8

Slide 8 text

Lifecycle of a JavaScript application @jessilyneh Loading the JavaScript application source code Analyzing the source code Compiling the source code into machine code.

Slide 9

Slide 9 text

@jessilyneh

Slide 10

Slide 10 text

Lifecycle of a JavaScript application @jessilyneh Loading the JavaScript application source code Analyzing the source code Compiling the source code into machine code. Optimizing the code

Slide 11

Slide 11 text

Optimizing the code @jessilyneh

Slide 12

Slide 12 text

Optimizing the code @jessilyneh

Slide 13

Slide 13 text

Optimizing the code inlining @jessilyneh

Slide 14

Slide 14 text

Lifecycle of a JavaScript application @jessilyneh Loading the JavaScript application source code Analyzing the source code Compiling the source code into machine code. Optimizing the code Creating the main object and global scope

Slide 15

Slide 15 text

Lifecycle of a JavaScript application @jessilyneh Loading the JavaScript application source code Analyzing the source code Compiling the source code into machine code. Optimizing the code Creating the main object and global scope Executing the code

Slide 16

Slide 16 text

Lifecycle of a JavaScript application @jessilyneh Loading the JavaScript application source code Analyzing the source code Compiling the source code into machine code. Optimizing the code Creating the main object and global scope Executing the code event management

Slide 17

Slide 17 text

Lifecycle of a JavaScript application @jessilyneh Loading the JavaScript application source code Analyzing the source code Compiling the source code into machine code. Optimizing the code Creating the main object and global scope Executing the code event management end of execution

Slide 18

Slide 18 text

@jessilyneh Javascript Engines!

Slide 19

Slide 19 text

V8: used in Google Chrome @jessilyneh

Slide 20

Slide 20 text

@jessilyneh SpiderMonkey: used in Mozilla Firefox

Slide 21

Slide 21 text

@jessilyneh Chakra: Used in Microsoft Edge

Slide 22

Slide 22 text

@jessilyneh JavaScriptCore: Used in Apple's Safari

Slide 23

Slide 23 text

@jessilyneh Code performance techniques

Slide 24

Slide 24 text

@jessilyneh

Slide 25

Slide 25 text

@jessilyneh Lazy Loading

Slide 26

Slide 26 text

@jessilyneh Deboucing

Slide 27

Slide 27 text

@jessilyneh Web Workers

Slide 28

Slide 28 text

@jessilyneh Does anyone here use only pure JavaScript in applications?

Slide 29

Slide 29 text

@jessilyneh The more libraries, the more complexity, the more performance problems

Slide 30

Slide 30 text

@jessilyneh it depends

Slide 31

Slide 31 text

@jessilyneh React performance problems

Slide 32

Slide 32 text

Use React @jessilyneh React performance problems

Slide 33

Slide 33 text

@jessilyneh just kidding!

Slide 34

Slide 34 text

Components re-rendering unnecessarily @jessilyneh React performance problems

Slide 35

Slide 35 text

Components re-rendering unnecessarily React performance problems @jessilyneh This is not a Javascript problem

Slide 36

Slide 36 text

Components re-rendering unnecessarily React performance problems @jessilyneh How can we monitor this problem?

Slide 37

Slide 37 text

@jessilyneh react-devtools

Slide 38

Slide 38 text

@jessilyneh react-devtools

Slide 39

Slide 39 text

@jessilyneh Performance Monitor Developer Tools Google Chrome

Slide 40

Slide 40 text

@jessilyneh Monitoring 1 requisition X 1000 requisitions monioring

Slide 41

Slide 41 text

@jessilyneh Autocannon Benchmarking tool written in Node.js

Slide 42

Slide 42 text

@jessilyneh Climem Monitor the memory consumption of your node process via CLI

Slide 43

Slide 43 text

@jessilyneh Clinic.js

Slide 44

Slide 44 text

@jessilyneh

Slide 45

Slide 45 text

@jessilyneh APM Tools - N|Solid

Slide 46

Slide 46 text

@jessilyneh

Slide 47

Slide 47 text

Special Tips for web developers @jessilyneh Learn Core Web Vitals Google

Slide 48

Slide 48 text

Thank you <3 in/jessilyneh/ @jessilyneh

Slide 49

Slide 49 text

References @jessilyneh O'Reilly - High Performance JavaScript https://blog.matheuscastiglioni.com.br/desconstruindo-a-web-como-v8-funciona/ https://efcl.info/2016/03/06/ast-first-step/ https://medium.com/dailyjs/understanding-v8s-bytecode-317d46c94775 https://devporai.com.br/5-dicas-para-otimizar-codigo-javascript/ https://geekflare.com/es/best-javascript-online-compilers/ O'Reilly - David Flanagan - “JavaScript: the Definitive Guide https://www.freecodecamp.org/news/execution-context-how-javascript-works-behind- the-scenes/

Slide 50

Slide 50 text

References @jessilyneh https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Memory_management https://medium.com/@selmankoral/memory-management-in-javascript-781e1098e5b3 https://loadninja.com/articles/debug-javascript-performance/ https://www.wmtips.com/html/lazy-loading-definitive-guide/ https://www.freecodecamp.org/news/javascript-debounce-example/ https://woliveiras.com.br/posts/o-que-e-para-que-serve-throttle%20/ https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Memory_management https://web.dev/articles/workers-basics?hl=pt-br https://www.freecodecamp.org/news/how-webworkers-work-in-javascript-with-example/

Slide 51

Slide 51 text

References @jessilyneh https://github.com/facebook/react/blob/main/packages/react-devtools/CHANGELOG.md https://developer.chrome.com/docs/devtools/performance/reference/ https://github.com/mcollina/autocannon https://www.nearform.com/blog/tracking-memory-allocation-node-js/ https://github.com/mcollina/climem https://clinicjs.org/ https://github.com/clinicjs/node-clinic https://youtu.be/CS03W_YSdJc?si=DrbejVSkuTnUkaR0