
PageSpeed Insights flags “Reduce unused JavaScript” and “Reduce unused CSS” — your pages ship code nobody runs. The reduce unused JavaScript CSS fix is one of the highest-leverage speed wins on WordPress: every unused kilobyte still downloads, parses, and competes for the main thread, hurting LCP and INP directly. This 2026 guide shows you how to find the dead code and remove it safely, without breaking your site.
Why does WordPress ship so much unused code? Themes and plugins load their full CSS and JavaScript on every page “just in case” — the contact-form scripts load on blog posts, the slider library loads where there is no slider, and page builders inject styles for widgets you never used. Chrome DevTools’ Coverage tab routinely shows 50–80% of shipped CSS and JS going unused on a typical WordPress page. That waste is pure overhead.
What Causes Unused JavaScript and CSS
- Plugins loading everywhere: contact forms, galleries, and sliders enqueueing assets on pages that do not use them.
- Page-builder bloat: builders output CSS for every widget in their library, used or not.
- jQuery and legacy libraries: loaded for one old plugin while the rest of the site uses vanilla JS.
- Unused theme features: bundled sliders, icon fonts, and animation libraries you never enabled.
- Third-party widgets: chat, review, and social embeds dragging in full SDKs for a small button.
- Aggressive “combine” settings: merging everything into one file forces every page to download all of it.
How to Reduce Unused JavaScript and CSS: 8 Steps
Step 1: Measure the waste with the Coverage tab
In Chrome DevTools, press Ctrl+Shift+P, type “Show Coverage”, reload the page, and record. The Coverage tab shows exactly what percentage of each CSS and JS file actually executes. Sort by unused bytes — the biggest red bars are your targets. Take a screenshot; you will compare against it later.
Step 2: Remove plugins you do not need
List every active plugin and ask what each one does for visitors. Deactivate and delete the ones with no clear job — each removed plugin deletes its CSS/JS from every page load. Replace heavy plugins with lighter alternatives where a swap exists.
Step 3: Unload assets per page
Use a script manager (Perfmatters, Asset CleanUp, or WP Rocket’s exclusions) to disable specific CSS/JS files on pages that do not need them: contact-form scripts only on the contact page, gallery scripts only on gallery pages, slider libraries only where a slider exists. This is the single biggest unused-code win on most WordPress sites.

Step 4: Defer and delay what remains
Defer non-critical JavaScript so it loads after the page renders (defer attribute — WordPress supports 'strategy' => 'defer' natively since 6.3). Delay heavier scripts (chat widgets, analytics add-ons) until user interaction. Always exclude above-the-fold interactive scripts like the mobile menu from delaying.
Step 5: Remove unused CSS automatically
Enable “Remove Unused CSS” (WP Rocket) or “Used CSS” generation in your caching plugin, which builds a per-page stylesheet containing only the CSS that page needs. Test thoroughly — aggressive unused-CSS removal can break layouts on complex themes, so check desktop and mobile after enabling.
Step 6: Drop jQuery if nothing needs it
Check whether your theme or plugins still require jQuery (jQuery.fn.jquery in the console). On Gutenberg-based sites with modern plugins, deregistering jQuery on the frontend can drop 30–80 KB. Test forms and sliders afterwards — keep it if a plugin breaks without it.
Step 7: Tame third-party embeds
Replace embedded YouTube videos with click-to-load preview images, load chat widgets only on contact and pricing pages, and audit every tracker in your tag manager. Each third-party embed is JavaScript you do not control — facades and delayed loading cut their cost dramatically.
Step 8: Re-measure and lock it in
Re-run the Coverage tab and PageSpeed Insights after each change — unused bytes should drop and the “Reduce unused JavaScript/CSS” warnings should shrink or vanish. Document which assets you unloaded per page so future plugin installs do not silently reintroduce the bloat. For the server-side half of speed, read our slow server response fix.
How to Prevent Code Bloat Returning
Adopt a plugin diet: every new plugin must justify its asset weight, and script managers should be configured for new page types as you create them. Review the Coverage tab quarterly — updates to themes and plugins quietly reintroduce unused code. Keep a free performance audit tool in your routine to catch regressions early.
Conclusion
Unused JavaScript and CSS are dead weight your visitors pay for on every load: measure with Coverage, unload per page, defer and delay the rest, and remove unused CSS automatically. The result is faster LCP, better INP, and happier visitors. For more WordPress speed wins, keep reading the KamiWeb blog.
