Jimmy Breck-McKye

A lazy programmer

Simple Optimization Patterns in JavaScript

NOTES

  • Memoize
  • Throttle
  • Debounce
  • Promise
  • Lazy
  • Batch

Memoize

Break your code into ‘pure’ functions, and cache their results.

Throttle

Limit the rate at which a function can be called.

Debounce

Don’t execute a function until it hasn’t been called in a while.

Once

Create a function that only calls its implementation once.

Yield

Let pending user actions take priority over this function call.

Batch

Collect all the changes a script wants to make, and run them in a single pass

DOM Batching

Batch up DOM writes and reads for minimal layout steps.

Comments