Install a page cache plugin, a minifier, a lazy-loader, an "asset cleanup" plugin and a database optimizer, and you get five output buffers rewriting the same HTML, two plugins fighting over wp-content/advanced-cache.php, and a TTFB that still spikes to 1.8 s the moment a WooCommerce session cookie bypasses the cache. WordPress speed optimization without plugin stacking means fixing the request at the layer where the cost is created: PHP bootstrap, the options table, the object cache, the enqueue queue, and the HTTP response. Below is the exact code, SQL and server config, with the trade-offs spelled out.
Table of Contents
- Why Plugin Stacking Fails
- The Request Pipeline You Are Optimizing
- Step 1: Strip Core Front-End Bloat
- Step 2: Conditional WooCommerce Asset Dequeueing
- Step 3: Persistent Object Caching
- Step 4: Clean Up wp_options Autoload
- Step 5: Preload the LCP Image and Fonts
- Step 6: Edge Caching and HTTP Headers
- Targets and Benchmarks
- Troubleshooting
- Related Content
Why Plugin Stacking Fails
Speed plugins mostly treat symptoms in the HTML after WordPress has already done the expensive work.
A minifier can't make a 2 MB autoloaded options payload smaller. A lazy-load plugin can't reduce the 40 database queries that ran before the first byte. And caching plugins collide in predictable ways:
-
advanced-cache.phpis a single file. WhenWP_CACHEistrue, WordPress loadswp-content/advanced-cache.phpbefore almost anything else. Only one plugin can own it. Install a second page cache and it silently overwrites the first one's drop-in, or refuses to activate. -
Output buffers stack. Each optimizer that rewrites HTML opens its own
ob_start()callback. Three of them means the full document is parsed three times per uncached request. -
Defer and delay scripts conflict. Two plugins both adding
deferor "delay until interaction" to jQuery is the classic cause of a broken variation form or a dead add-to-cart button.
Verdict: one page cache at the server or edge, and everything else in code you can read.
The Request Pipeline You Are Optimizing
Every uncached WordPress request walks the same path. Each step below maps to one section of this guide.
graph LR
A[Uncached Request] --> B[PHP Bootstrap]
B --> C{Object Cache Hit}
C -->|Yes| D[alloptions from Redis]
C -->|No| E[wp_options Autoload Query]
D --> F[Main Query and Template]
E --> F
F --> G[Conditional Asset Dequeue]
G --> H[HTML with Preload Hints]
H --> I[Cache Control Headers]
I --> J[Edge CDN Delivery]
J --> K[Browser]
The left half decides TTFB. The right half decides LCP and INP. Fix them in that order: there is no point preloading a font on a page that took 1.2 s to start sending HTML.
Step 1: Strip Core Front-End Bloat
Put the following in a must-use plugin at wp-content/mu-plugins/kx-lean.php. Must-use plugins load before regular plugins, can't be deactivated from the dashboard, and need no settings screen.
<?php
/**
* Plugin Name: Kinetix Lean Front End
* Description: Removes unused core front-end output. No settings, no options rows.
*/
defined( 'ABSPATH' ) || exit;
add_action( 'init', function () {
// Emoji detection script and styles. Since WordPress 6.4 the styles are
// enqueued by wp_enqueue_emoji_styles; print_emoji_styles is deprecated.
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_enqueue_scripts', 'wp_enqueue_emoji_styles' );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_enqueue_scripts', 'wp_enqueue_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
add_filter( 'emoji_svg_url', '__return_false' );
// oEmbed discovery links and the wp-embed host script.
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
remove_action( 'wp_head', 'wp_oembed_add_host_js' );
// Head noise with no runtime value.
remove_action( 'wp_head', 'rsd_link' );
remove_action( 'wp_head', 'wp_generator' );
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10 );
} );
add_action( 'wp_enqueue_scripts', function () {
if ( is_user_logged_in() ) {
return;
}
// Dashicons are only needed for the admin bar on the front end.
wp_dequeue_style( 'dashicons' );
// Heartbeat has no job for anonymous visitors.
wp_deregister_script( 'heartbeat' );
}, 100 );
// Logged-in editors: keep Heartbeat (autosave, post locks) but slow it down.
add_filter( 'heartbeat_settings', function ( $settings ) {
$settings['interval'] = 60; // Seconds. Core clamps the value to 15–120.
return $settings;
} );
What each block actually saves:
| Removal | What disappears from the page | Risk |
|---|---|---|
| Emoji script and styles | One inline detection script, one inline style block, a DNS hint for s.w.org
|
Older browsers show native emoji glyphs instead of Twemoji images |
| oEmbed discovery and host JS | Two <link rel="alternate"> tags; wp-embed on pages with post embeds |
Other sites can't auto-embed your posts as rich cards |
| Dashicons for visitors | A render-blocking stylesheet with an embedded icon font | Breaks any front-end plugin that uses Dashicons without declaring the dependency |
| Heartbeat for visitors | Periodic admin-ajax.php POST requests, if a plugin enqueued it |
Front-end plugins that list heartbeat as a dependency stop loading |
| Heartbeat interval 60 s | Fewer admin-ajax.php hits per open editor tab |
Post-lock warnings appear a little later |
Leave the REST API alone. Removing rest_output_link_wp_head is harmless, but disabling REST itself breaks the block editor, WooCommerce blocks, and the Store API that the cart and checkout blocks depend on.
Advanced: dropping jQuery Migrate on the front end
jquery-migrate is still registered as a dependency of jquery. If your theme and plugins don't use deprecated jQuery APIs, you can drop it on the front end only:
add_action( 'wp_default_scripts', function ( $scripts ) {
if ( is_admin() || empty( $scripts->registered['jquery'] ) ) {
return;
}
$scripts->registered['jquery']->deps = array_diff(
$scripts->registered['jquery']->deps,
array( 'jquery-migrate' )
);
} );
Test the variation form, quantity buttons, mini cart and any slider first. With SCRIPT_DEBUG enabled, Migrate logs a JQMIGRATE: console warning for every deprecated call; zero warnings across a full checkout flow means it is safe to remove.
Step 2: Conditional WooCommerce Asset Dequeueing
WooCommerce enqueues its stylesheets and core scripts on every front-end URL, including blog posts and the About page.
The stylesheets are woocommerce-general, woocommerce-layout and woocommerce-smallscreen, plus wc-blocks-style when blocks are involved. The scripts are woocommerce and wc-add-to-cart. Since WooCommerce 7.8, wc-cart-fragments is no longer loaded globally; it only appears when a cart widget or a theme asks for it.
add_action( 'wp_enqueue_scripts', function () {
if ( ! class_exists( 'WooCommerce' ) ) {
return;
}
// Store pages keep everything.
if ( is_woocommerce() || is_cart() || is_checkout() || is_account_page() ) {
return;
}
// Pages that embed products through blocks or shortcodes keep everything too.
$post = get_post();
if ( $post instanceof WP_Post && (
str_contains( $post->post_content, '<!-- wp:woocommerce/' ) ||
has_shortcode( $post->post_content, 'products' ) ||
has_shortcode( $post->post_content, 'product_page' ) ||
has_shortcode( $post->post_content, 'add_to_cart' )
) ) {
return;
}
foreach ( array( 'woocommerce-general', 'woocommerce-layout', 'woocommerce-smallscreen', 'wc-blocks-style' ) as $handle ) {
wp_dequeue_style( $handle );
}
foreach ( array( 'woocommerce', 'wc-add-to-cart', 'wc-cart-fragments' ) as $handle ) {
wp_dequeue_script( $handle );
}
}, 99 );
Priority 99 makes sure WooCommerce (default priority 10) has already enqueued what you are removing. Dependencies such as BlockUI and js-cookie drop out automatically once nothing that needs them is left in the queue.
Two cases where you should not dequeue:
-
A header mini cart. If your theme shows a cart count in the header on every page, removing
wc-cart-fragmentson blog posts leaves a stale count behind a page cache. Either keep fragments or switch to the Mini-Cart block, which reads from the Store API. -
Order attribution. WooCommerce's Order Attribution feature (8.5+) records the landing page and traffic source through the
sourcebuster-jsandwc-order-attributionscripts. Dequeue them on blog posts and every order from a visitor who arrived through a blog post loses its source. If you don't use attribution, switch it off under WooCommerce > Settings > Advanced > Features instead.
For the product template itself, the biggest savings come from removing gallery scripts you don't use and replacing jQuery tabs with native <details> elements, both covered in how to edit a WooCommerce product page without a builder.
Step 3: Persistent Object Caching
Without a persistent object cache, every request starts with an empty WP_Object_Cache and rebuilds options, term lists, product lookups and transients from MySQL.
A persistent backend keeps those results in memory between requests. Since WordPress 6.1, Site Health flags sites without one. The usual setup is Redis plus an object-cache.php drop-in in wp-content/. A drop-in is not a plugin in the stacking sense: it replaces the cache class, registers no hooks on the page, and rewrites no HTML.
On Ubuntu or Debian, install Redis and the PHP extension, then cap its memory in /etc/redis/redis.conf so it evicts least-recently-used keys instead of growing until the box swaps:
sudo apt install redis-server php-redis
sudo systemctl enable --now redis-server
maxmemory 256mb
maxmemory-policy allkeys-lru
// wp-config.php, above "That's all, stop editing!"
define( 'WP_CACHE_KEY_SALT', 'shop.example.com:' ); // Unique per site on a shared Redis.
define( 'WP_REDIS_HOST', '127.0.0.1' );
define( 'WP_REDIS_PORT', 6379 );
define( 'WP_REDIS_DATABASE', 0 );
define( 'WP_REDIS_MAXTTL', DAY_IN_SECONDS );
The WP_REDIS_* constants are read by the widely used open-source Redis drop-in; managed hosts often install their own drop-in and only expose the salt. Confirm the backend is live:
wp cache type
redis-cli info stats | grep -E "keyspace_(hits|misses)"
wp cache type should print Redis, not Default.
A healthy WooCommerce store usually settles above a 90% hit ratio after a few minutes of traffic. Below 70%, look for plugins calling wp_cache_flush() on every save.
One side effect matters for Step 4: with a persistent object cache active, transients are stored in Redis instead of wp_options, so the options table stops growing with expiring rows.
Step 4: Clean Up wp_options Autoload
On every request without a warm object cache, WordPress runs one query that loads every autoloaded option into memory before your theme runs a single line.
WordPress 6.6 changed how this works. The autoload column now accepts on, off, auto, auto-on and auto-off alongside the legacy yes and no. Options larger than 150 KB are no longer autoloaded by default (filterable through wp_max_autoloaded_option_size), and Site Health warns when the total autoloaded size passes 800 KB.
Measure the total first:
SELECT ROUND(SUM(LENGTH(option_value)) / 1024) AS autoload_kb,
COUNT(*) AS autoloaded_rows
FROM wp_options
WHERE autoload IN ('yes', 'on', 'auto-on', 'auto');
Then find the heaviest rows:
SELECT option_name,
ROUND(LENGTH(option_value) / 1024, 1) AS kb,
autoload
FROM wp_options
WHERE autoload IN ('yes', 'on', 'auto-on', 'auto')
ORDER BY LENGTH(option_value) DESC
LIMIT 25;
Replace wp_ if your table prefix differs. Typical offenders: settings left behind by uninstalled plugins, analytics or log arrays written by active plugins, and old builder caches. Fix them through the API rather than raw UPDATE statements, so the alloptions cache stays consistent (wp_set_options_autoload() exists since WordPress 6.4):
Run these in order: stop autoloading options that are only read on one admin screen, delete rows left by plugins you already removed, then clear expired transients and flush the object cache.
wp eval 'wp_set_options_autoload( array( "old_plugin_settings", "some_plugin_log" ), false );'
wp option delete old_plugin_settings
wp transient delete --expired
wp cache flush
| Option pattern | Safe to stop autoloading? | Notes |
|---|---|---|
rewrite_rules |
No | Needed on every request; regenerated by saving Permalinks |
cron |
No | Read on every request by WP-Cron |
active_plugins, template, stylesheet
|
No | Core bootstrap depends on these |
| Uninstalled plugin settings | Delete them | Confirm the plugin is gone from wp-content/plugins/ first |
| Plugin logs or stats arrays | Yes | Read only on that plugin's admin screen |
_transient_* rows |
Usually | With Redis active they shouldn't be in the table at all |
WooCommerce adds one more table to watch: wp_actionscheduler_actions. Completed actions are kept for 30 days by default. On busy stores that is hundreds of thousands of rows:
add_filter( 'action_scheduler_retention_period', function () {
return WEEK_IN_SECONDS;
} );
Step 5: Preload the LCP Image and Fonts
Since WordPress 6.3, core adds fetchpriority="high" to the image it expects to be the LCP element in post content. WooCommerce's main product image is rendered outside post content by the gallery, so set the hint yourself:
add_filter( 'woocommerce_gallery_image_html_attachment_image_params', function ( $params, $attachment_id, $image_size, $main_image ) {
if ( $main_image ) {
$params['fetchpriority'] = 'high';
$params['loading'] = 'eager';
}
return $params;
}, 10, 4 );
Fonts: self-host WOFF2 files and preload only the one weight used above the fold. WordPress 6.1 added the wp_preload_resources filter for exactly this:
add_filter( 'wp_preload_resources', function ( $resources ) {
$resources[] = array(
'href' => get_theme_file_uri( 'assets/fonts/inter-var-latin.woff2' ),
'as' => 'font',
'type' => 'font/woff2',
'crossorigin' => 'anonymous',
);
return $resources;
} );
The crossorigin attribute is required even for same-origin fonts; without it the browser downloads the file twice. Pair every preloaded font with font-display: swap in its @font-face rule to keep CLS at zero during the swap.
WordPress 6.8 also ships speculative loading in core: prefetch with conservative eagerness for logged-out visitors on sites with pretty permalinks. Core already skips URLs with query strings, so ?add-to-cart= links are safe, but exclude the stateful store paths:
add_filter( 'wp_speculation_rules_href_exclude_paths', function ( $paths ) {
return array_merge( $paths, array( '/cart/*', '/checkout/*', '/my-account/*' ) );
} );
Step 6: Edge Caching and HTTP Headers
A full-page cache in Nginx or at the CDN replaces the page cache plugin entirely. The only hard part with WooCommerce is knowing which requests must never be cached.
The first part goes inside the server block, before the PHP location; the fastcgi_* lines go inside location ~ \.php$; the static asset block sits alongside it. WordPress appends ?ver= to asset URLs whenever they change, so a one-year immutable cache is safe.
set $skip_cache 0;
if ($request_method = POST) { set $skip_cache 1; }
if ($query_string != "") { set $skip_cache 1; }
if ($request_uri ~* "/(cart|checkout|my-account)/|/wp-admin/|/wp-json/") { set $skip_cache 1; }
if ($http_cookie ~* "wordpress_logged_in_|woocommerce_items_in_cart|wp_woocommerce_session_|comment_author") {
set $skip_cache 1;
}
fastcgi_cache WORDPRESS;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache_valid 200 301 10m;
fastcgi_cache_use_stale error timeout updating http_500 http_503;
add_header X-Cache $upstream_cache_status;
location ~* \.(css|js|woff2|webp|avif|svg|png|jpg)$ {
add_header Cache-Control "public, max-age=31536000, immutable";
access_log off;
}
Check the result with headers, not with a speed score:
curl -sI https://shop.example.com/product/hoodie/ | grep -iE "x-cache|cache-control|server-timing"
The first request should show X-Cache: MISS, the second HIT. At the CDN, honour the origin's Cache-Control and forward the same cookie bypass list; never cache responses that contain a Set-Cookie header.
Kinetix approaches the theme layer with the same thinking: a block-editor theme built on clean hook architecture with no builder runtime, so there is less to strip before any of the server work above starts paying off. If you are building or auditing your own theme layer, see our blueprint for WordPress custom block theme development with theme.json v3. The Kinetix getting started guide covers installation, and the Kinetix changelog lists front-end weight changes release by release.
Targets and Benchmarks
These are the thresholds worth tracking at the 75th percentile of real visits (field data from CrUX or your own RUM), not a single lab run.
| Metric | Good | Poor | Main lever in this guide |
|---|---|---|---|
| TTFB | 800 ms or less | Above 1,800 ms | Steps 3, 4 and 6 |
| LCP | 2.5 s or less | Above 4.0 s | Steps 5 and 6 |
| INP | 200 ms or less | Above 500 ms | Steps 1 and 2 |
| CLS | 0.1 or less | Above 0.25 | Step 5 (font-display, image dimensions) |
| Autoloaded options | Under 800 KB | Site Health warning | Step 4 |
How the approaches compare on a typical WooCommerce store:
| Approach | Moving parts | Fixes TTFB on cache miss | Debuggability |
|---|---|---|---|
| Five stacked plugins | 5 settings screens, 3+ output buffers | No | Low: conflicts are silent |
| One page cache plugin | 1 settings screen, advanced-cache.php
|
Only on cache hits | Medium |
| Code plus server stack (this guide) | 1 mu-plugin, Redis drop-in, Nginx config | Yes: autoload and object cache cut bootstrap cost | High: every change is in Git |
Product data matters too: large variable products inflate both HTML weight and query time, so revisit the threshold tuning in our WooCommerce product variations guide after you finish here. Likewise, replacing heavy field-builder plugins with native register_post_meta() cuts wp_postmeta row counts in half—see our blueprint on WordPress custom fields without a plugin.
Troubleshooting
The add-to-cart button or variation form stopped working
Almost always Step 2 running on a page that renders products outside the conditions it checks, for example a product grid in a widget, a footer template part, or a page-builder module. Add the page to the early return (for example with is_page( 'shop-landing' )) or detect the block or shortcode where it actually lives. Check the browser console for woocommerce is not defined or wc_add_to_cart_params is not defined.
Redis is connected but the hit ratio stays low
Look for code that flushes the whole cache. Some plugins call wp_cache_flush() on every post save or every cron run. Search the codebase:
grep -rn "wp_cache_flush" wp-content/plugins wp-content/themes
Also confirm WP_CACHE_KEY_SALT is unique when several sites share one Redis instance; colliding keys cause sites to evict each other.
Logged-in shoppers still get slow pages
That is expected: logged-in and cart-holding sessions bypass the page cache by design. Their speed comes from Steps 3 and 4. Turn on SAVEQUERIES on staging, or check the Server-Timing header if your host emits one, to see what dominates the uncached request. More than 100 queries on a product page usually points to an extension running uncached meta lookups.
Autoload size didn't drop after cleanup
You changed the rows but the old alloptions payload is still sitting in the object cache. Run wp cache delete alloptions options or wp cache flush. If the size climbs back within a day, an active plugin is rewriting its option with autoload on. When the plugin relies on the default autoload value, the wp_default_autoload_value filter (WordPress 6.6+) can force that option name to false; when it passes autoload explicitly, only the author can fix it.
Related Content
-
How to Remove jQuery From WordPress Safely (No Plugin): audit
$wp_scriptsdependencies, stripjquery-migrate, dequeuejquery-coreon the front end when unused, and replace legacy patterns with vanilla JS. - How to Edit a WooCommerce Product Page Without a Builder: reorder the product summary with hooks, swap jQuery tabs for native accordions, and cut gallery scripts that hurt LCP and INP.
-
WordPress Custom Block Theme Development: Full FSE Guide: replace monolithic stylesheets and page builders with
theme.jsonv3 tokens and on-demand per-block CSS. -
How to Add Product Variations in WooCommerce (Without Wrecking Your Database): keep variable products lean in
wp_postsandwp_postmeta, and tune the AJAX variation threshold so large catalogs stay fast.
Originally published at https://kinetix.software/blog/wordpress-speed-optimization-without-plugin.
Top comments (0)