Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Increase your JS performance with memoization

Increase your JS performance with memoization

How to decrease CPU time of various front-end operations with Memoization and how to avoid re-renders with newly available React.memo() and useMemo hook.

Aditya Agarwal

January 13, 2019
Tweet

More Decks by Aditya Agarwal

Other Decks in Technology

Transcript

  1. It is a measure of how fast a task is

    finished by Javascript
  2. So, what are the options available to us? use web

    workers, delegate it to server
  3. We can extract memoization into its own function Then we

    won’t need to rewrite all our code.
  4. fn is the function to memoize fn is called with

    argument return a function which will take argument
  5. Some things to keep in mind... • Only applicable on

    pure functions. • Keep a check on cache size. • Cache invalidation. • Current solution is for one argument. • Use lodash for more robust implementation.