Skip to main content

Performance Considerations

warning

Performance problems are usually cumulative: heavy blocks + unoptimized images + third-party scripts + uncached pages. Test as a full stack, not in isolation.

Performance Considerations Explained

AreaRiskMitigation
CSS sizeRender-blocking and style recalculationKeep presets minimal, avoid huge custom CSS
JS sizeINP regressionsAvoid unnecessary scripts
ImagesLCP and CLSCompress, set dimensions, use responsive images
CachingStale output vs speedPurge LSCache after layout changes

Why It Matters

  • GenerateBlocks is lightweight, but layouts can still get heavy.
  • Performance is a product feature; treat it as part of design.
  • OLS + LSCache can hide changes until cache is purged.

How It Works

Front-end performance is driven by what the browser downloads (CSS/JS/images) and what it has to render (DOM depth). GenerateBlocks affects both.

flowchart LR
CSS[CSS] --> R[Render]
JS[JS] --> R
IMG[Images] --> R
DOM[DOM depth] --> R
R --> UX[User experience]

Practical Walkthrough

Step 1: Audit Build Asset Sizes

audit-generateblocks-build-assets.sh
cd /var/www/html
ls -lh wp-content/plugins/generateblocks/build 2>/dev/null | head -n 80 || true

Step 2: Locate Key Build Files (Source Hints)

locate-key-build-files.sh
cd /var/www/html
ls -lh wp-content/plugins/generateblocks/build/style-index.css 2>/dev/null || true
ls -lh wp-content/plugins/generateblocks/build/frontend.js 2>/dev/null || true

Step 3: Check for Cache Headers (Optional)

check-lscache-headers.sh
URL="$(wp option get siteurl 2>/dev/null)/"
curl -I "$URL" 2>/dev/null | grep -i litespeed || true

Step 4: Find Large Images in Uploads (Optional)

find-large-uploads.sh
cd /var/www/html
du -ah wp-content/uploads 2>/dev/null | sort -hr | head -n 20 || true

Practical Examples

Example 1: Reduce DOM Depth

Rules of thumb:

  • Avoid containers inside containers inside containers.
  • Use one wrapper per section.
  • Prefer CSS grid/flex over extra wrapper blocks.

Example 2: Image Hygiene for Heroes

Checklist:

  • Use WebP/AVIF where possible
  • Set width/height
  • Avoid huge background images

Example 3: Third-Party Script Containment

If a block section requires a third-party script:

  • Load it only on pages that need it
  • Prefer async/defer
  • Document it in a runbook

Example 4: A Simple Page Budget Table

BudgetTarget
Total hero image bytes< 250KB
Third-party scriptsas few as possible
Custom CSS per pagenear zero

Best Practices

PracticeWhy
Keep blocks reusable and minimalLess DOM, fewer regressions
Set performance budgets per sectionPrevents slow creep
Warm cache before testingAvoids false negatives
Purge cache after deploymentsEnsures you see real output
Test logged-outLogged-in views can bypass caching
Avoid heavy animationsJS-heavy effects often regress INP

Troubleshooting

SymptomCauseFix
Page feels slowLarge images or JSAudit hero images and third-party scripts
Layout shiftsLate-loaded fonts/imagesSet dimensions and reduce font variants
Changes not visibleCachePurge LSCache and re-test
INP regressedToo much JSRemove effects, reduce scripts, and simplify block nesting
No cache headersCache not configuredVerify LSCache setup and test a public URL logged-out

Hands-On

  1. List build asset sizes and note the largest files.
  2. Pick one hero section and optimize its image to a smaller size.
  3. Re-test the page logged-out with cache warmed.
  4. Capture response headers before and after a cache purge and document the difference.

Quick Reference

performance-cheatsheet.sh
cd /var/www/html
ls -lh wp-content/plugins/generateblocks/build 2>/dev/null | head
curl -I "$(wp option get siteurl 2>/dev/null)/" 2>/dev/null | grep -i litespeed || true

What's Next