Skip to main content
File optimization shrinks your CSS and JavaScript and changes how the browser executes them. Each toggle has a small risk of breaking something visual or interactive, so enable them one at a time and test.

CSS

ToggleWhat it does
Minify CSSStrips whitespace and comments from CSS files. Saves roughly 20–30% file size. Almost always safe.
Combine CSSConcatenates multiple CSS files into a smaller number of bundles. Saves on TCP round-trips.
Critical Path CSSInlines the above-the-fold CSS into the HTML so first paint doesn’t wait for the external file. The rest is loaded asynchronously.
Don’t combine CSS if your server speaks HTTP/2. HTTP/2 multiplexes many requests over one connection, so combining buys nothing and can hurt cache reuse. Most modern stacks (including ours) are HTTP/2 by default.

Excluded CSS Files

A textarea for files you want to skip from minification or combining. One per line. Useful when a CSS file uses dynamic includes that minification breaks, or a third-party stylesheet must stay separate (e.g., a payment gateway’s iframe styles).
*/payment-gateway/*
*/woocommerce/inline.css

Aggressive mobile CSS optimization

A subtoggle that reduces excluded files on mobile. Off by default. Can break visual styling. Enable only if you’re testing carefully on mobile and have a way to roll back.

JavaScript

ToggleWhat it does
Minify JavaScriptStrips whitespace and comments. ~20% size reduction, almost always safe.
Combine JavaScriptsBundles multiple JS files into fewer requests. Same HTTP/2 caveat as CSS.
Load JavaScript deferredAdds the defer attribute to script tags so they load after the HTML is parsed.
Delay JavaScript ExecutionWaits to load non-critical JS until the user interacts (scrolls, clicks). Big TTFB win, but breaks JS that needs to run on initial page load.

Combine vs Defer vs Delay (in plain terms)

  • Defer says “browser, run this script after parsing the HTML.” Safe for most scripts. Good default.
  • Delay says “browser, don’t even fetch this script until the user does something.” Useful for analytics, chat widgets, share buttons. Will break scripts that need to execute on page load (carousels, accordions, anything that hooks DOMContentLoaded).
  • Combine says “merge multiple files into one.” Now mostly redundant in HTTP/2.

Apply Delay JS only on mobile devices

A subtoggle. Limits Delay JavaScript Execution to mobile only, leaving desktop as-is. Useful when a delay breaks desktop interactions but mobile is fine (or vice versa).

Excluded scripts and rules

If a single JS file shouldn’t be deferred or delayed (commonly: jQuery on themes that depend on it loading immediately, or a payment gateway script):
RuleWhat it covers
Excluded JavaScript FilesSkip these files from minification, combining, or defer. One pattern per line.
Excluded CSS FilesSame idea, for CSS.
Patterns support * wildcards.

A safe rollout

Don’t enable everything at once. The order we recommend:
  1. Minify CSS (lowest risk).
  2. Test the site, including a checkout flow if you have one.
  3. Minify JavaScript.
  4. Test again, with a focus on interactive elements (sliders, modals, AJAX).
  5. Load JavaScript deferred.
  6. Test the homepage and a content-heavy page.
  7. Skip Combine on HTTP/2 stacks; otherwise enable last.
  8. Delay JavaScript Execution is the highest-risk toggle. Try it last and only if you’ve already squeezed everything else.
After each step, run a PageSpeed test against a key page to confirm the change actually helped.

Common issues

Either a CSS file uses an unusual syntax minification can’t handle, or the file is dynamically generated with placeholders. Find the offending file via DevTools (the broken element’s computed styles will be missing) and add the file path to Excluded CSS Files.
Likely Delay JavaScript Execution is delaying a script that needs to run on page load. Disable Delay first to confirm. If that’s it, exclude the affected scripts via Excluded JavaScript Files (jQuery and theme JS bundles are common offenders) and re-enable Delay.
A nonce or CSRF token in a JS file may be getting cached after minification. Add the file to Excluded JavaScript Files, or move the token output into an inline script tag (which isn’t combined or minified).
Either the site’s bottleneck isn’t on the JS/CSS side (in which case X-Ray the slowest PHP), or HTTP/2 was already handling multiplexing. Use a waterfall diagnostic (DevTools → Network → Disable cache → reload) to see where the actual time is going.

Need a hand?