Roadmap › JavaScript (ES5 → ES2025) & TypeScript Basics › Module: Advanced and TypeScript
Lessons in this course (16)

15. Memory leaks, performance and security

AdvancedMediumLesson 15 of 16
  • Memory leaks: forgotten timers/intervals, event listeners on removed elements, global variables, closures holding large data, detached DOM nodes, growing caches. Find with DevTools Memory → heap snapshots.
  • Performance: code splitting and lazy loading, tree shaking, minification, compression, caching (HTTP + service worker), avoid long tasks (> 50 ms), virtualise long lists, debounce input, use defer, optimise images, measure Core Web Vitals (LCP, INP, CLS).
  • Security: XSS (never insert untrusted HTML — use textContent, sanitise with DOMPurify, Content-Security-Policy), CSRF (SameSite cookies, tokens), avoid eval/new Function, validate on the server, keep dependencies patched (npm audit), Subresource Integrity for CDN scripts.