Zero-Base Loading Strategy

Traditional themes load their entire stylesheet and script bundle on every page, regardless of what the page actually uses. Aegis takes the opposite approach:

  1. Default state: No theme CSS, no theme JS, no web fonts loaded.
  2. Block detection: During rendering, Aegis detects which blocks are present on the page.
  3. Conditional loading: Only the styles and scripts required by those blocks are enqueued.
  4. Result: Pages that use only core blocks may load with zero theme-specific assets.

What This Means in Practice

Page ContentAssets Loaded
Simple page with only paragraphs and imagesZero theme CSS/JS (core styles only)
Page with a Slider blockSlider CSS + Slider JS only
Page with Countdown + ToggleCountdown CSS/JS + Toggle CSS/JS
WooCommerce product pageWooCommerce integration styles only

Conditional Asset Loading

How It Works

The asset loading system operates in three phases:

  1. Registration — All available assets are registered with WordPress but not enqueued.
  2. Detection — Block parsing identifies which blocks and variations are present in the content.
  3. Enqueueing — Only the assets required by detected blocks are added to the page.

Block-Level Granularity

Each custom block and enhanced core block declares its own dependencies:

Copied!
JSON
// Example: Slider block registers its own assets'style' => 'aegis-slider', // Frontend CSS'script' => 'aegis-slider', // Frontend JS'editor_style' => 'aegis-slider-editor', // Editor-only CSS

These assets are only loaded when the block appears on the page.

Plugin Integration Styles

Plugin-specific compatibility styles follow the same pattern:

Font Loading Strategy

Fonts are a significant performance factor. Aegis optimizes font loading:

Self-Hosted Fonts

All fonts (Lexend, Lexend Deca, JetBrains Mono) are served from the theme directory:

Variable Fonts

Using variable font files reduces the number of HTTP requests:

Font Display Strategy

Fonts use font-display: swap:

Conditional Font Loading

theme.json declares the font faces, and browsers download a woff2 file only when text on the page uses that family:

Image Optimization

Aegis supports WordPress native image optimization:

Video Facades

With the Aegis Video add-on active, the Video block uses a facade pattern:

  1. A lightweight thumbnail image is displayed initially.
  2. The video player (iframe or native) loads only when the user clicks play.
  3. This eliminates heavy third-party script loading on page load.

Facades only play YouTube (youtube.com, youtube-nocookie.com) and Vimeo (player.vimeo.com) player URLs over HTTPS. Other embeds render as normal, without a facade.

Pattern and Icon Loading

Since 1.0.2, Aegis no longer runs every pattern file or lists every icon on each request.

ItemWhat Aegis doesCache
PatternsReads only each file’s header and registers the pattern with its file path. WordPress runs a pattern file only when its content is used.aegis_pattern_headers option (not autoloaded)
IconsLists each icon folder’s SVG file names once (about 5,700 files)aegis_icon_files option (not autoloaded)

How the caches stay current:

The gain is largest on hosts that restrict file access with open_basedir, where each file check is costly. WooCommerce’s variation scripts (underscore, wp-util, wc-add-to-cart-variation) also load only where a variable product form needs them.

You do not need to clear these caches. Edits to a pattern’s content show right away. A changed header (title, categories, slug) is picked up the next time the editor, REST API, or WP-CLI loads the pattern list.

Critical Rendering Path

Aegis minimizes render-blocking resources:

Resource TypeLoading Strategy
Theme CSSConditional, only per-block styles
Theme JSDeferred, conditional per-block
FontsPreloaded for above-the-fold content
ImagesLazy loaded below the fold
VideosFacade until interaction
AnalyticsAsync/defer, non-blocking

Measuring Performance

Core Web Vitals

Aegis is optimized for Google Core Web Vitals:

MetricTargetHow Aegis Helps
LCP (Largest Contentful Paint)< 2.5sMinimal CSS, font preloading, no JS blocking
FID (First Input Delay)< 100msDeferred JS, minimal main-thread work
CLS (Cumulative Layout Shift)< 0.1Explicit image dimensions, font-display swap
INP (Interaction to Next Paint)< 200msLightweight event handlers, no heavy frameworks

Testing Tools

ToolPurpose
WPAuditWordPress-specific performance audit
LighthouseGeneral web performance scoring
WebPageTestDetailed waterfall analysis
PageSpeed InsightsField data + lab data analysis

Running WPAudit

Copied!
Shell
composer test:wpaudit

See Testing for more details on running performance tests.

Caching Compatibility

Aegis works with all major caching solutions:

Bundle Size

The theme produces minimal asset bundles:

AssetTypical Size
Per-block CSS1–5 KB (gzipped)
Per-block JS2–10 KB (gzipped)
Font file (variable)30–60 KB (per family)
Total typical pageUnder 50 KB theme assets

Developer Performance Tips

When building custom pages or templates:

  1. Prefer core blocks — They have zero theme asset cost.
  2. Minimize custom block usage — Each custom block adds its CSS/JS bundle.
  3. Use patterns — Patterns are just block markup, not additional assets.
  4. Avoid global stylesheets — Do not add blanket CSS that loads everywhere.
  5. Test with Lighthouse — Verify performance after significant changes.

Next Steps