Fix guides · Performance
How to reduce unused CSS, minify CSS and JavaScript, and remove duplicate code
Stylesheets full of rules the page never uses, files that still contain comments and spaces, and the same library shipped twice. How to trim them on Shopify, WordPress, Webflow, Wix, Squarespace and Next.js.
- Time to fix
- 30–90 minutes
- Skill needed
- Developer
- Who notices
- Every visitor: more to download before the page is ready
Why it matters
Minifying removes comments, spaces and long names from CSS and JavaScript files. The code works the same and downloads faster.
Unused CSS is styling for parts of the site that aren't on this page, often from a theme, page builder or plugin that loads everything everywhere.
Duplicated JavaScript means the same library is downloaded more than once, usually because two scripts each bundle their own copy.
“The numbers don’t lie—82.7% of these wasted bytes come from an organization’s own scripts, while third-party code chips in a smaller but still notable 17.3%.”
Before you start
- Check whose files are listed. Your own theme or build can be fixed; app, plugin and widget files are up to their developers.
- Minifying is safe and automatic with any build tool or optimization plugin. Removing unused CSS is riskier: a rule unused on this page may be needed on another, or after a click.
- For duplicated JavaScript, the report names the module. Make sure only one version of it is installed and loaded.
Fix it on your platform
Shopify
- Files from an app's own domain, or from cdn.shopify.com/extensions/, usually belong to apps. Remove apps you don't use.
- If your theme's own CSS or JavaScript is listed as unminified, minify it in your theme's build step, or ask the theme developer. Shopify's Theme Check linter also flags oversized bundles.
- Two apps loading their own copy of the same library (for example jQuery) show up as duplicated JavaScript. Ask the app developers, or keep only one of the apps.
WordPress
- A performance or caching plugin can minify CSS and JavaScript. Turn on one option at a time and check your pages.
- Many plugins load their styles on every page. Deactivate unused plugins, and use plugin settings (or an asset manager plugin) to load the rest only where needed.
- Page builders and multipurpose themes ship large stylesheets; a lighter theme removes most unused CSS.
Webflow
- Webflow can minify your site's HTML, CSS and JavaScript: in Site settings → Publishing, turn on the minify options under Advanced publishing options, then publish. Test the site afterwards.
- Delete unused classes in the Style selectors panel to shrink your stylesheet.
Wix Managed by the platform
- Wix builds and minifies its own CSS and JavaScript; you can't change them.
- If files from apps or custom code are listed, remove the ones you don't need.
Squarespace Managed by the platform
- Squarespace builds its own CSS and JavaScript; you can't change them.
- If files from code injection, custom CSS or extensions are listed, minify your own code before pasting it and remove what you don't use.
Next.js
- Production builds (next build) minify CSS and JavaScript automatically. If files are flagged as unminified, check you aren't serving a development build, and look for scripts loaded from /public.
- Unused CSS often comes from global stylesheets imported in the root layout. Move component styles into CSS Modules or the components that use them.
- For duplicates, check that only one version of a package is installed (npm ls package-name) and that you're not also loading it from a CDN.
Any other site
- Minify CSS and JavaScript as part of your build (any bundler does this), or with an online minifier for small sites.
- Split CSS by page, or remove rules your site no longer uses (Chrome DevTools' Coverage panel shows unused CSS).
- Load each library once, from one place.
Check that it's fixed
- Re-run your StudioLNC audit: the files you changed should no longer be listed, or show smaller savings.
- Click through pages and menus that depend on the CSS you removed.
Find every issue like this on your site
Free audit of performance, accessibility, SEO and security, with fixes for your platform.