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:
- Default state: No theme CSS, no theme JS, no web fonts loaded.
- Block detection: During rendering, Aegis detects which blocks are present on the page.
- Conditional loading: Only the styles and scripts required by those blocks are enqueued.
- Result: Pages that use only core blocks may load with zero theme-specific assets.
What This Means in Practice
| Page Content | Assets Loaded |
|---|---|
| Simple page with only paragraphs and images | Zero theme CSS/JS (core styles only) |
| Page with a Slider block | Slider CSS + Slider JS only |
| Page with Countdown + Toggle | Countdown CSS/JS + Toggle CSS/JS |
| WooCommerce product page | WooCommerce integration styles only |
Conditional Asset Loading
How It Works
The asset loading system operates in three phases:
- Registration — All available assets are registered with WordPress but not enqueued.
- Detection — Block parsing identifies which blocks and variations are present in the content.
- 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:
- WooCommerce styles load only on WooCommerce pages.
- LMS styles load only on course/lesson pages.
- Form styles load only when a form block is present.
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:
- No external requests to Google Fonts or other CDNs.
- Fonts are available immediately without DNS lookup or connection overhead.
- Full control over caching headers.
Variable Fonts
Using variable font files reduces the number of HTTP requests:
- One file for Lexend covers weights 300–900.
- One file for Lexend Deca covers weights 300–900.
- One file for JetBrains Mono (
jetbrainsslug) covers weights 100–900, upright only.
Font Display Strategy
Fonts use font-display: swap:
- Text is immediately visible using a system font fallback.
- Custom fonts swap in once loaded.
- No flash of invisible text (FOIT).
- Minimal flash of unstyled text (FOUT) due to similar font metrics.
Conditional Font Loading
theme.json declares the font faces, and browsers download a woff2 file only when text on the page uses that family:
- JetBrains Mono downloads only when code text is on the page.
- Lexend Deca downloads when headings are present.
Image Optimization
Aegis supports WordPress native image optimization:
-
Responsive images —
srcsetandsizesattributes for proper resolution selection. -
Lazy loading — Images below the fold use
loading="lazy". - Aspect ratio — Explicit width and height attributes prevent layout shift.
- WebP/AVIF — Works with WordPress image format conversion.
Video Facades
With the Aegis Video add-on active, the Video block uses a facade pattern:
- A lightweight thumbnail image is displayed initially.
- The video player (iframe or native) loads only when the user clicks play.
- 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.
| Item | What Aegis does | Cache |
|---|---|---|
| Patterns | Reads 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) |
| Icons | Lists each icon folder’s SVG file names once (about 5,700 files) |
aegis_icon_files option (not autoloaded) |
How the caches stay current:
- A folder is listed again when its modified time changes. Adding, removing, or renaming a pattern or icon does that.
- The editor, the REST API, and WP-CLI re-read a pattern’s header when its file changes. Front-end requests use the cached headers. Pattern content is always read from the file.
- If a template asks for a pattern slug that is not registered, that request re-checks every pattern file, so a renamed slug works on the front end right away.
- The pattern cache starts fresh when the active theme or its version changes, so a theme update never serves old pattern headers.
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 Type | Loading Strategy |
|---|---|
| Theme CSS | Conditional, only per-block styles |
| Theme JS | Deferred, conditional per-block |
| Fonts | Preloaded for above-the-fold content |
| Images | Lazy loaded below the fold |
| Videos | Facade until interaction |
| Analytics | Async/defer, non-blocking |
Measuring Performance
Core Web Vitals
Aegis is optimized for Google Core Web Vitals:
| Metric | Target | How Aegis Helps |
|---|---|---|
| LCP (Largest Contentful Paint) | < 2.5s | Minimal CSS, font preloading, no JS blocking |
| FID (First Input Delay) | < 100ms | Deferred JS, minimal main-thread work |
| CLS (Cumulative Layout Shift) | < 0.1 | Explicit image dimensions, font-display swap |
| INP (Interaction to Next Paint) | < 200ms | Lightweight event handlers, no heavy frameworks |
Testing Tools
| Tool | Purpose |
|---|---|
| WPAudit | WordPress-specific performance audit |
| Lighthouse | General web performance scoring |
| WebPageTest | Detailed waterfall analysis |
| PageSpeed Insights | Field data + lab data analysis |
Running WPAudit
Copied!Shellcomposer test:wpaudit
See Testing for more details on running performance tests.
Caching Compatibility
Aegis works with all major caching solutions:
- Page caching — Full page cache safe (no user-specific content in templates).
- Object caching — Compatible with Redis and Memcached.
- CDN — All static assets use cache-friendly URLs.
- Browser caching — Assets include proper cache headers.
Bundle Size
The theme produces minimal asset bundles:
| Asset | Typical Size |
|---|---|
| Per-block CSS | 1–5 KB (gzipped) |
| Per-block JS | 2–10 KB (gzipped) |
| Font file (variable) | 30–60 KB (per family) |
| Total typical page | Under 50 KB theme assets |
Developer Performance Tips
When building custom pages or templates:
- Prefer core blocks — They have zero theme asset cost.
- Minimize custom block usage — Each custom block adds its CSS/JS bundle.
- Use patterns — Patterns are just block markup, not additional assets.
- Avoid global stylesheets — Do not add blanket CSS that loads everywhere.
- Test with Lighthouse — Verify performance after significant changes.
Next Steps
- Aegis Dash Performance — Free site-wide toggles (oEmbed, dashicons, heartbeat, head/API cleanup, embed facades) and Pro emoji / Query Loop Performance. With Pro active, the theme defers emoji stripping to that toggle; free-plugin and standalone theme installs keep zero-base frontend emoji removal. Standalone theme enables embed facades by default; with Aegis Dash they default off until toggled.
- Testing — Running performance tests
- Building Assets — Understanding the build process.
- Deployment — Production deployment considerations.