Chakde System Design Series - Optimization Techniques

Jul 2, 2024

Chakde System Design Series - Optimization Techniques

Introduction

  • Optimization is crucial for web development and in-demand for web applications
  • Important for senior developer roles and interview questions
  • Focus on network optimization in this episode, with asset, build, and monitoring optimization in future episodes

Types of Optimization Techniques

  • Asset Optimization (JavaScript, CSS, images)
  • Network Optimization
  • Build Optimization
  • Monitoring

Network Optimization Topics Covered

  1. Lazy Loading
  2. Loading JavaScript in Async Fashion
  3. Content Visibility
  4. Serving Critical CSS
  5. Resource Hints
  6. Caching
  7. Client-Side Rendering
  8. Server-Side Rendering
  9. Compression Techniques
  10. Avoiding Layout Shift and Repaint

Detailed Topics

Lazy Loading

  • Delays resource loading to improve performance
  • Use loading attribute in images and iframes:
    • lazy for non-critical resources
    • eager for critical resources
  • Use Intersection Observer API for effective lazy loading

Loading JavaScript Asynchronously

  • Add async attribute to script tag to allow downloading in parallel without blocking parsing
  • Use defer attribute to download and execute script after HTML parsing is complete

Content Visibility

  • Use CSS content-visibility: auto for lazy rendering
  • Reduces rendering time significantly
  • Only renders visible content in the viewport

Serving Critical CSS

  • Split CSS into critical and non-critical parts
  • Load critical CSS synchronously
  • Load non-critical CSS using `media=