JavaScript theorytheory 0/50 · 0%
Performance · hard

46. Performance basics

Measuring before optimising.

Profile first: most slowness comes from network waterfalls, oversized bundles and re-rendering, not from arithmetic. Batch RPC calls, cache immutable results, debounce input handlers and lazily load heavy modules.

const debounced = (fn, ms) => {
  let t; return (...a) => { clearTimeout(t); t = setTimeout(() => fn(...a), ms); };
};

Immutable chain data — a mined block, a token's decimals — can be cached forever.

Check your understanding

  1. 1. What usually dominates dApp latency?

  2. 2. What does debouncing do?

  3. 3. Which data is safe to cache indefinitely?