Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Page Loading Performance Strategies

Page Loading Performance Strategies

Slides from a talk first presented at ReactFoo Delhi 2018.

Featured projects:
1. Buuuk
2. Guiding Tech
3. Design Fabric

Prateek Rungta

August 18, 2018
Tweet

More Decks by Prateek Rungta

Other Decks in Technology

Transcript

  1. #perf Combine CSS & JS Minification Unused CSS CDN GZIP

    HTTP/2 Automation Bundling Caching VPS Image Optimisation DNS prefetch Responsive Images Lazy loading Image Sprites Async Service Workers Server Push Code Splitting
  2. #1

  3. ✓ Combine CSS, JS ✓ Minify, Gzip ✓ HTTP/2 ✓

    VPS ✓ CDN ✓ Lazyloading ✓ Image optimisation ✓ Responsive images
  4. CSS JS Fonts Icons Parse Compile Render Request Page 1

    CSS JS Fonts Icons Parse Compile Render Request Page 2 CSS JS Fonts Icons Pars Comp Rend Requ Page 3
  5. Parse Render Parse Render Page 1 CSS JS Fonts Icons

    Page 2 Page 3 Parse Compile Render Request
  6. 1. Intercept click 2. Request HTML over Ajax 3. Update

    <title> and <body> 4. Push new browser history state PJAX
  7. ✓ No server side conditionals ✓ Minimal markup changes ✓

    Graceful degradation ✓ Preserves Back button functionality
  8. ✓ At least 300ms of gain in speed ✓ Clicks

    will start to appear instant ✓ Again, no extra config on the server
  9. #2

  10. There are only two hard things in Computer Science: cache

    invalidation and naming things.” – Phil Karlton “
  11. Delete Delete, Rebuild Rebuild, Replace No out-of-sync pages returned ✓

    ✓ × Cache regenerates automatically ✓ × ✓ Server load is distributed ✓ × ✓ All users get a cached response × – ✓
  12. Change Time No redundant invalidation ✓ × Staggered expiry of

    caches × ✓ Cache layer decoupled from App × ✓
  13. 1. Full page cache 2. Short, time based expiry 3.

    Re-generate, then replace Microcaching
  14. ✓ All users get a cached response ✓ Cached content

    no older than 2 seconds ✓ Cache layer decoupled from App layer ✓ Staggered expiry & regeneration
  15. #3

  16. 1. Prioritise critical rendering path 2. Defer loading images that

    are not visible 3. Visual feedback that improves perception of speed Lazy loading
  17. 1. Create different sized images 2. Use srcset attribute to

    inform browser 3. Use sizes attribute to help browser choose the right size Responsive Images
  18. ✓ Fewer bytes to download ✓ Fewer pixels to decode

    ✓ Future-proof for higher DPI screens
  19. 1. Strip metadata 2. Lossless compression 3. Lossy compression 4.

    Efficient image formats (WebP, WebM, H.264 for GIFs etc.) Compression