Automatically reorders the <head> of your WordPress pages for optimal browser rendering and web performance using the Capo.js methodology.
In standard WordPress setups, WordPress Core, block themes, SEO plugins (like Yoast SEO), analytics scripts (like Site Kit/GTM), and third-party plugins all inject tags into wp_head() at arbitrary priorities.
This leads to common performance pitfalls:
⚠️ Late Page Titles: Heavy SEO meta tags or inline JSON-LD output before<title>.⚠️ Delayed Network Connections: Async analytics scripts and preconnects pushed after dozens of stylesheet and style blocks.⚠️ Render Blocking: Preloads and font styles buried beneath third-party scripts.
Capo solves this automatically by intercepting the page response via output buffering and stably sorting all <head> elements according to their impact on the browser's critical rendering path.
Capo groups elements into 11 strictly evaluated priority weights (from 10 down to 0):
| Weight | Visual | Category | Elements & Detection |
|---|---|---|---|
| 10 | 🟪 | Critical Meta & Viewport | <base>, <meta charset>, <meta name="viewport">, critical http-equiv headers (CSP, origin-trial, accept-ch) |
| 9 | 🟥 | Title | <title> |
| 8 | 🟧 | Preconnect | <link rel="preconnect"> |
| 7 | 🟧 | Async Script | <script src="..." async> |
| 6 | 🟨 | CSS @import | <style> blocks containing @import rules |
| 5 | 🟨 | Sync Scripts | Synchronous/inline JavaScript (<script> without defer/async) |
| 4 | 🟩 | Stylesheets & Styles | <link rel="stylesheet">, <style> blocks |
| 3 | 🟩 | Preload | <link rel="preload">, <link rel="modulepreload"> |
| 2 | 🟦 | Defer Script | <script src="..." defer>, <script src="..." type="module"> |
| 1 | 🟫 | Prefetch / Prerender | <link rel="prefetch">, <link rel="dns-prefetch">, <link rel="prerender"> |
| 0 | ⬜ | Other Metadata | OpenGraph, Twitter cards, Schema JSON-LD, RSS feeds, favicons, generator tags |
Note
Deterministic Stable Sort: Elements with equal priority weight retain their exact sequential order, preserving CSS cascade specificity and JavaScript dependency execution.
- Zero Configuration: Activate and your
<head>is immediately optimized. - Cache Compatible: Integrates seamlessly with page caching solutions like WP Super Cache, W3 Total Cache, WP Rocket, and LiteSpeed Cache (static cached HTML stores the optimized
<head>with 0ms runtime overhead). - Safe HTML Tokenizer: Respects HTML comments, conditional comments (
<!--[if ...]>), CDATA blocks, and inline script markup. - Site Health Integration: Adds a diagnostic check under Tools > Site Health to verify optimization status.
- Testing & Bypass Mode: Append
?capo=offto any frontend URL to inspect the raw un-reordered head.
- Go to Plugins > Add New.
- Upload the
capo.ziparchive or search for Capo. - Click Install Now and Activate.
- Clone this repository into your plugins directory:
git clone https://github.com/rviscomi/capo-wp.git /var/www/html/wp-content/plugins/capo
- Activate via WP-CLI:
wp plugin activate capo
- If using a page cache plugin, flush your cache:
wp super-cache flush
Capo for WordPress is maintained with 1:1 parity against @rviscomi/capo.js.
# Run PHP standalone unit tests
php tests/test-rules.php
php tests/test-parser.php
# Run cross-language parity assertions (Node.js + PHP)
npm run test:parityCheck npm for upstream updates, auto-upgrade dependencies, regenerate PHP rules, and run parity tests in one step:
npm run update-upstreamOr manually regenerate and package:
npm run sync-rules
npm run test:parity
npm run packageCapo for WordPress is open-source software licensed under the GPL-2.0-or-later.