Performance plugins offer options to minify, combine, defer and delay CSS and JavaScript. Used well, they make pages load and respond faster. Used carelessly, they break menus, sliders, forms and checkouts. This guide explains what each option does and how I enable them safely on client sites.
Minification
Minification removes whitespace, comments and unnecessary characters from CSS and JavaScript files without changing how they work. It reduces file sizes, sometimes significantly for large unminified files.
Most themes and plugins already ship minified files, so the gains may be modest. Minification is generally safe, but occasionally breaks poorly written scripts. Enable it, test the site and exclude any files that cause problems.
Combining files
Combining merges multiple CSS or JavaScript files into one, reducing the number of requests. This mattered with HTTP/1.1, where each request was costly. With HTTP/2 and HTTP/3, browsers download many files in parallel efficiently, so combining brings little benefit.
Combining can also hurt caching, because changing one small file invalidates the whole combined file, and it can cause script order problems. On modern hosting with HTTP/2, I usually leave combining off. See HTTP/2, HTTP/3 and Brotli.
| Option | Benefit | Risk |
|---|---|---|
| Minify | Smaller files | Low |
| Combine | Fewer requests | Medium, little gain on HTTP/2 |
| Defer JS | Faster rendering | Low to medium |
| Delay JS | Less main-thread work | Medium |
| Remove unused CSS | Less render-blocking | Medium |
| Critical CSS | Faster first render | Medium |
Deferring JavaScript
Scripts in the head without defer or async block HTML parsing until they are downloaded and run. The defer attribute tells the browser to download scripts in parallel and run them in order after the HTML is parsed. This speeds up rendering without changing script order.
Deferring is usually safe for most scripts, but inline scripts that depend on a deferred library can break, for example inline code expecting jQuery. Good performance plugins handle this, and you can exclude specific scripts if needed.
Async scripts
The async attribute downloads scripts in parallel and runs them as soon as they are ready, in any order. It suits independent scripts such as analytics that do not depend on other code. Using async for scripts that depend on each other causes errors.
Most third-party tags provide async snippets by default. For your own site scripts, defer is usually safer than async.
Delaying JavaScript until interaction
Delay JavaScript features, available in WP Rocket, LiteSpeed Cache, Perfmatters and others, prevent scripts from loading until the visitor scrolls, clicks or presses a key. This greatly reduces initial main-thread work, improving lab scores and often INP.
Delay non-essential scripts such as chat widgets, analytics, marketing pixels and social embeds. Be careful with scripts needed immediately, such as menus, sliders above the fold, cookie consent and checkout functionality. Exclude those from delay.
Removing unused CSS
Many pages load large stylesheets where only a small part is used. Remove unused CSS features analyse each page and load only the styles needed, loading the full stylesheet later or not at all. This reduces render-blocking and speeds up the first render.
It can cause missing styles for elements that appear after interaction, such as dropdown menus or popups. Test interactive elements after enabling, and add safelists for classes that must always load. See reducing unused JavaScript and CSS.
Critical CSS
Critical CSS inlines the styles needed for the first screen in the HTML and loads the rest asynchronously. The first screen renders faster because the browser does not wait for the full stylesheet. Plugins can generate it automatically per template.
If critical CSS is incomplete, visitors may briefly see unstyled content. Regenerate critical CSS after design changes. See eliminating render-blocking resources.
A safe testing process
Enable one option at a time on a staging site or during a quiet period. After each change, clear all caches and test the homepage, a service or product page, blog posts, forms, the menu on mobile and, for stores, add to cart and checkout.
Check the browser console for JavaScript errors. If something breaks, disable the last option or exclude the specific file. Keep notes of exclusions so future changes do not undo them.
Common breakages and fixes
Mobile menus that stop opening usually mean a menu script was delayed or deferred incorrectly; exclude it. Sliders that show all slides stacked mean the slider script is delayed; exclude it or replace the slider. Forms that do not submit often depend on a delayed script or a cached nonce.
Checkout problems in WooCommerce are often caused by optimising scripts on checkout pages. Many plugins exclude WooCommerce pages automatically, but verify. When in doubt, exclude cart and checkout from JavaScript optimisation entirely.
Measuring the impact
Compare PageSpeed Insights results before and after each change, focusing on LCP, Total Blocking Time and the render-blocking and unused code diagnostics. Lab results change immediately; field data takes weeks.
Check real interactions too. A good lab score with a broken menu is not an improvement. Real users and conversions matter more than numbers.
Getting help
Configuring these options without breaking the site takes experience with each theme, builder and plugin combination. It is a core part of my speed optimization service.
For choosing the plugin that provides these features, read WP Rocket vs LiteSpeed Cache vs W3 Total Cache.
Key takeaways
- Minify and defer are usually safe; combining brings little benefit on HTTP/2.
- Delay non-essential scripts but exclude menus, consent and checkout.
- Enable one option at a time and test interactive elements after each.
- Exclude cart and checkout from aggressive JavaScript optimisation.
Frequently asked questions
Should I combine CSS and JavaScript files?
Usually not on HTTP/2 or HTTP/3 hosting. Combining adds risk with little benefit.
What is the difference between defer and async?
Defer runs scripts in order after parsing; async runs each script as soon as it downloads, in any order.
Why does my menu break after optimisation?
The menu script was probably delayed or deferred incorrectly. Exclude it from optimisation.
Is delaying JavaScript safe for SEO?
Yes, if content is in the HTML. Avoid delaying scripts that create essential content.
Do I need critical CSS?
It helps render-blocking issues, especially on heavy themes. Test carefully and regenerate after design changes.
