Skip to content

CSS Performance Optimization #18

@matt-project-q

Description

@matt-project-q

CSS Performance Optimization

Optimize render-blocking CSS to improve page load performance and Lighthouse scores.

Current Issues

Lighthouse Performance Report:

  • Render blocking requests: Est savings of 490 ms
  • /assets/main.css: 107.3 KiB, 610ms load time
  • Blocking initial page render and delaying LCP (Largest Contentful Paint)

Current Setup:

  • CSS is not minified (1,682 lines with spaces, newlines, comments)
  • Loaded synchronously in <head> (blocking render)
  • No SASS compression configured
  • 16 SCSS partial files, some very large (939, 762, 725 lines)

Optimization Tasks

Quick Wins (GitHub Pages Compatible):

  • Enable SASS compression in _config.yml
    sass:
      style: compressed
    Expected impact: 40-60% file size reduction (107KB → ~45-65KB)

Advanced Optimizations:

  • Identify critical above-the-fold CSS
  • Create _includes/critical.scss with essential styles (~10-14KB)
  • Inline critical CSS in head.html
  • Defer non-critical CSS loading using async technique
  • Split SCSS partials into critical vs. non-critical

Critical CSS Split Strategy:

  • Critical: variables, colors, typography, core layout, navigation essentials
  • Deferred: components, books, search, social, contact-form, responsive enhancements

Expected Impact

SASS Compression Only:

  • File size: 107KB → ~45-65KB (40-60% reduction)
  • Impact: Moderate improvement

Critical CSS + Async Loading:

  • Initial render: ~10-14KB inline CSS (instant, no blocking)
  • Deferred load: ~50KB compressed CSS (non-blocking)
  • LCP improvement: ~400-500ms faster
  • Lighthouse Performance: +10-20 points

Implementation Options

  1. Easy (5 min): Enable SASS compression only
  2. Moderate (1-2 hours): Critical CSS inlining + async loading
  3. Comprehensive (4-6 hours): Full hybrid approach with split partials

Success Criteria

  • Reduce render-blocking CSS to under 14KB inline
  • Eliminate render-blocking warning from Lighthouse
  • Improve LCP metric by 400ms+
  • Maintain visual consistency (no flash of unstyled content)
  • GitHub Pages compatible (no custom plugins)

Resources

Notes

  • Deferred from Phase 7 snagging
  • Consider starting with SASS compression for quick win
  • Critical CSS requires ongoing maintenance as styles change

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions