</head> so they load before first paint. All fixes toggle individually in WP Admin → Settings → Divi SpeedWorks, and a Tier 2 system lets you add site-specific custom dequeues through a config file.
The Problem With Divi Out of the Box
Divi is one of the most popular WordPress themes — and for good reason. The visual builder is powerful, the Theme Builder gives you global header, footer, and template control, and the page-building experience is genuinely fast once you know your way around it.
But what Divi ships by default is a different story. Activate Divi on a fresh WordPress install and your frontend page loads carry a set of assets that don't belong there: Gutenberg block editor stylesheets (you're not using Gutenberg), WordPress core global styles (overridden by Divi anyway), duplicate CSS enqueues from child theme hooks, and an admin-only Divi builder script that fires on every public page for no reason.
None of these are catastrophic individually. But they compound. A PageSpeed Insights run on a typical Divi 4 site will flag render-blocking resources, unused CSS, and a Cumulative Layout Shift score above zero — all attributable to how Divi's enqueue stack interacts with WordPress core. These are fixable problems, and fixing them doesn't require a managed performance suite or a CDN subscription. It requires knowing which hooks to call and which styles to dequeue.
Divi SpeedWorks packages those fixes into a plugin that activates clean and requires no configuration for the common case.
The Two-Tier Architecture
The plugin is organized into two tiers that reflect two different categories of performance fix:
Tier 1 contains hardcoded optimizations that are safe across every Divi 4 installation. These are fixes for things Divi does wrong by default — shipping assets that have no business being on a Divi-powered frontend. Tier 1 runs automatically when the plugin is active, without reading a config file or checking site-specific state.
Tier 2 handles per-site enqueue cleanup. Every WordPress site accumulates plugin scripts and stylesheets that load globally but aren't needed on every page — a contact form plugin loading its validation JS on a blog post, a gallery plugin loading lightbox CSS on the homepage. Tier 2 gives you a structured way to register those dequeues once, in a config file, and have them applied automatically on every frontend request.
The CLS fix sits outside both tiers. It's a separate class (DSW_CLS_Fix) that uses output buffering to address a specific Divi Theme Builder behavior. Because it touches the entire HTML output rather than the enqueue stack, it's architecturally distinct from the dequeue-based fixes in Tiers 1 and 2.
Tier 1: The Seven Built-in Fixes
The DSW_Built_In_Fixes class defines nine optimizations (with some targeting the same resource via multiple hooks). Here's what each one removes and why it shouldn't be there:
1. Remove dc_enqueue_styles
Some Divi child themes call dc_enqueue_styles() in their functions.php to enqueue the parent theme's stylesheet alongside a child stylesheet. This is a common pattern from the pre-Divi-4 era, but in Divi 4, it causes the parent theme CSS to load twice — once via Divi's own enqueue and once via the child theme's explicit call. The fix removes the dc_enqueue_styles action entirely, letting Divi handle its own stylesheet loading.
2. Remove wp_enqueue_global_styles
WordPress core outputs a <style> block of "global styles" tied to the block editor's design system — custom color palettes, spacing presets, typography settings. On a Divi site, these global styles serve no purpose because Divi manages all of that through its own options system. The fix removes wp_enqueue_global_styles from both wp_enqueue_scripts and wp_footer, which is where WordPress sneaks a fallback copy in on some theme configurations.
3–6. Dequeue Gutenberg Stylesheets
Activating WordPress core ships four block-editor stylesheets that load on every page, even when you've never touched the block editor:
wp-block-library— Base block styles for paragraphs, images, headings, etc.wp-block-library-theme— Theme-specific block style variantsglobal-styles— The computed stylesheet from the site editor's global styles panelclassic-theme-styles— Fallback styles WordPress adds when the active theme doesn't declare block support
Divi 4 doesn't use any of these. Its own builder output replaces them entirely. The plugin dequeues and deregisters all four on wp_enqueue_scripts at priority 100, after WordPress has finished registering them.
7. Dequeue et-core-common
et-core-common is Elegant Themes' shared JavaScript library — it powers inline editing, drag-and-drop builder controls, and other visual editing features. None of those are needed on a public-facing frontend page. Divi enqueues it everywhere by default rather than gating it to admin or builder contexts. The plugin dequeues it on wp_enqueue_scripts so it never loads on frontend page requests.
Each of these seven fixes is individually toggleable from the settings page. If one causes a conflict on a specific site — an unusual child theme that actually depends on dc_enqueue_styles, for example — you can disable that fix without rolling back the others.
How the Built-in Fixes Are Applied
The implementation in DSW_Built_In_Fixes is straightforward. The class defines a FIXES constant that maps each fix identifier to its type (remove_action, dequeue_style, or dequeue_script) and its WordPress hook target:
const FIXES = [
'dc_enqueue_styles' => ['type' => 'remove_action', 'hook' => 'wp_head'],
'wp_enqueue_global_styles' => ['type' => 'remove_action', 'hook' => 'wp_enqueue_scripts'],
'wp-block-library' => ['type' => 'dequeue_style'],
'wp-block-library-theme' => ['type' => 'dequeue_style'],
'global-styles' => ['type' => 'dequeue_style'],
'classic-theme-styles' => ['type' => 'dequeue_style'],
'et-core-common' => ['type' => 'dequeue_script'],
];
On initialization, the class iterates the FIXES array, checks whether each fix is enabled via the dsw_built_in_fix_overrides database option, and either calls remove_action() or hooks a wp_dequeue_style() / wp_dequeue_script() call at the right priority. The is_enabled() check defaults to true for every fix — opt-out rather than opt-in.
The CLS Fix: Output Buffering to Move Styles to <head>
The CLS fix addresses a specific behavior in Divi's Theme Builder. When you create a global page template, header, or footer in the Theme Builder, Divi injects the template's module CSS as an inline <style> block directly into the page body — not the <head>. It looks like this in the rendered HTML:
<body>
<!-- page content begins... -->
<style id="et-builder-module-design-header-cached-inline-styles">
/* theme builder template CSS */
.et_pb_section { ... }
.et_pb_row { ... }
</style>
<!-- more content... -->
</body>
The browser sees the page structure before it sees the styles that govern that structure. Under normal network conditions this might not be noticeable. Under throttled conditions — a mobile network, a slow connection, or just a server under load — the browser renders content with default styles first, then reflows when the inline stylesheet arrives. That reflow is Cumulative Layout Shift. It's not hypothetical; it shows up as a non-zero CLS score in PageSpeed Insights on virtually every Divi Theme Builder site.
How the Fix Works
The DSW_CLS_Fix class uses PHP output buffering to intercept the complete HTML response before it's sent to the browser:
add_action('template_redirect', function() {
ob_start([$this, 'process_output']);
}, 1); // Priority 1 — starts before Divi outputs anything
The process_output() callback receives the complete HTML string as its argument. It runs a preg_match_all() to find all <style> blocks whose IDs match the Divi Theme Builder pattern:
preg_match_all(
'/