↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

Performance Principles

The page treats performance as a set of practical questions: can you do less work, take a shorter route, avoid repeating work, or do some work ahead of time. It uses examples from programming and frontend work to show how those choices reduce cost or make navigation feel instant.

Reading notes
#

  • If only part of a dataset is needed, stop processing early instead of looping through everything.
  • For nested lookups, build a map or a Set so lookups are O(1) after an O(n) setup cost.
  • Caching avoids recalculating expensive results by storing them in a map and checking it first.
  • Prefetching page data and resources before navigation can make the next page load feel instant.
  • On mobile, where hover does not exist, prefetching can wait until the browser is idle with requestIdleCallback, with setTimeout as a fallback.
  • For image carousels, swiping the first image can trigger preloading of the remaining images.