Description
In standard WordPress sites, WordPress Core, themes, SEO plugins, analytics scripts, and third-party plugins inject elements into wp_head() in arbitrary order. This can lead to critical performance pitfalls:
- Delayed Title Tag Rendering: SEO metadata and large JSON-LD blocks placed before
<title>. - Delayed Resource Discovery: Preconnects, preloads, and async scripts pushed below dozens of CSS stylesheets.
- Render-Blocking Bottlenecks: External synchronous scripts blocking CSS and parser execution.
Capo solves this automatically. By intercepting the page response via output buffering, Capo uses a deterministic, stable sorting algorithm to reorder <head> elements strictly according to browser critical rendering path priorities.
The Capo Head Priority Spectrum
Capo organizes elements into 11 strict priority tiers (Weight 10 down to 0):
- Weight 10 (Critical Meta & Viewport):
<base>,<meta charset>,<meta name="viewport">, criticalhttp-equivheaders (CSP, origin-trial, accept-ch). - Weight 9 (Title):
<title>. - Weight 8 (Preconnect):
<link rel="preconnect">. - Weight 7 (Async Script):
<script src="..." async>. - Weight 6 (CSS @import Styles):
<style>blocks containing@importrules. - Weight 5 (Sync / Inline Scripts): Synchronous/inline JavaScript (
<script>without defer/async). - Weight 4 (Stylesheets & Style Blocks):
<link rel="stylesheet">,<style>blocks. - Weight 3 (Preload):
<link rel="preload">,<link rel="modulepreload">. - Weight 2 (Defer Script):
<script src="..." defer>,<script src="..." type="module">. - Weight 1 (Prefetch / Prerender):
<link rel="prefetch">,<link rel="dns-prefetch">,<link rel="prerender">,<script type="speculationrules">. - Weight 0 (Other Metadata): OpenGraph, Twitter cards, Schema JSON-LD, RSS feeds, favicons, robots metadata.
Features
- Zero Configuration: Activate the plugin and your
<head>is immediately optimized. - Deterministic Stable Sort: Equal-weight elements retain their exact relative order, preserving CSS cascade specificity and JavaScript dependencies.
- Full Cache Compatibility: Works seamlessly with WP Super Cache, W3 Total Cache, WP Rocket, LiteSpeed Cache, and Cloudflare.
- Safe HTML Tokenizer: Respects HTML comments, conditional comments (
<!--[if ...]>), CDATA blocks, and inline script markup. - Site Health & Admin Diagnostics: Real-time
<head>hygiene warnings and diagnostic status in Tools > Site Health and Admin Toolbar. - Testing & Bypass Mode: Append
?capo=offto any frontend URL to inspect the un-reordered head.
Screenshots


Installation
- Upload the plugin files to the
/wp-content/plugins/capo-head-optimizerdirectory, or install the plugin through the WordPress plugins screen directly. - Activate the plugin through the Plugins screen in WordPress.
- If you use a page caching plugin (e.g. WP Super Cache, WP Rocket), clear/flush your cache.
FAQ
-
Does Capo break script dependencies or stylesheet cascading?
-
No. Capo uses a deterministic stable sort. If you have multiple stylesheets (all Weight 4) or multiple scripts (all Weight 5), they will maintain their exact original relative order.
-
Does Capo work with page caching plugins?
-
Yes. Page caching plugins capture the output buffer generated by WordPress. With Capo activated, the cached HTML stored on disk or in memory will already have its
<head>sorted, incurring 0ms runtime overhead for cached visitors. -
How can I test the difference?
-
You can view any page with
?capo=offappended to the URL to bypass reordering and compare your raw<head>output against the optimized output.
Reviews
There are no reviews for this plugin.
Contributors & Developers
“Capo – Head Optimizer” is open source software. The following people have contributed to this plugin.
ContributorsTranslate “Capo – Head Optimizer” into your language.
Interested in development?
Browse the code, check out the SVN repository, or subscribe to the development log by RSS.
Changelog
0.1.3
- Added support for Speculation Rules API (
<script type="speculationrules">) classified as Weight 1 (Prefetch / Prerender) matching@rviscomi/capo.jsv2.2.1. - Enhanced HTML tokenizer and attribute parsing to robustly preserve tags with
>inside quoted attributes, boolean attributes, and empty string attributes. - Added full support for HTML conditional comments (
<!--[if ...]>) and CDATA sections in<head>. - Hardened Admin Toolbar diagnostic injection against regex backreference exploits using safe substring replacement.
- Added pass-by-reference
$analysisparameter and static accessor/reset methods to Parser for optimized memory lifecycle management. - Extended Site Health loopback check request timeout to 10 seconds via dynamic filter.
- Consolidated test bootstrap harness and added CI matrix testing across PHP 7.4 through 8.3.
0.1.2
- Adhered strictly to WordPress.org Plugin Directory guidelines and security standards.
- Changed debug performance HTML comment to opt-in by default and removed external URLs.
- Added uninstall.php handler to clean up database options on deletion.
- Fixed PHP 7.4 backwards compatibility in origin trial subdomain validation.
- Removed insecure sslverify override from Site Health loopback check.
- Enforced 5-tag maximum limit in readme metadata.
0.1.1
- Added
<head>validation engine with Origin Trial binary token decoding and origin/expiry checks. - Added live page diagnostics to frontend WordPress Admin Toolbar with scrollable warnings dropdown.
- Added HTML syntax highlighting and decoded token metadata table in WordPress Site Health.
- Improved toolbar integration and output buffering lifecycle.
0.1.0
- Initial public beta release.
- Output buffering engine for automatic
<head>reordering. - 1:1 parity with
@rviscomi/capo.jsrules and validation engine. - Site Health integration and bypass mode (
?capo=off).
