Fix Unused CSS & JS Warnings in 60 Seconds
Run a free speed test on your store — look for "Reduce unused CSS" and "Reduce unused JavaScript" in the Opportunities section. These warnings show you exactly how many kilobytes of dead code are blocking your page render. Thunder Page Speed Optimizer addresses both automatically:
- Defers non-critical CSS so it loads after the page renders
- Defers non-critical JavaScript (apps, analytics, widgets)
- Inlines critical CSS for above-the-fold content
- Optimizes script execution order to reduce main thread blocking
One click install. The warnings may not disappear completely (Shopify's core scripts can't be deferred), but Thunder reduces the impact by 60-80% for most stores.
Why Shopify Stores Have So Much Unused Code
Every Shopify store loads unused CSS and JavaScript. It's not a bug — it's how Shopify's architecture works. Understanding why helps you know what you can fix and what you can't.
1. Global Theme CSS
Shopify themes compile all CSS into one or two files (like base.css or theme.css) that load on every page. This file contains styles for the homepage, product pages, collection pages, cart, blog, account pages — everything. When someone visits your product page, they download cart drawer styles, collection grid styles, blog post styles, and account page styles they'll never use on that page.
A stock Dawn theme loads ~60KB of CSS. After customizations and additional CSS, that grows to 100-200KB. Premium themes can hit 200-400KB. On any single page, typically only 30-50% of this CSS is actually used.
2. App-Injected Code
Every Shopify app you install can inject JavaScript and CSS into your theme. Most apps inject their code globally — on every page — even if the app only does something on product pages or the cart. A review app loads its CSS on your About page. A cart upsell app loads its JS on blog posts. Each app typically adds 50-300KB of CSS/JS.
With 10 apps installed, you might be loading 500KB-3MB of app code on every page, with each page using only a fraction of it. See our analysis of apps that slow down your store for specific examples.
3. Orphaned Code from Uninstalled Apps
When you uninstall a Shopify app, it removes its backend functionality but often leaves behind code in your theme. Script tags in theme.liquid, Liquid snippets in the snippets/ folder, and inline CSS all persist after the app is removed. This is dead code that loads on every page for zero benefit.
4. Shopify's Own Scripts
Shopify injects its own JavaScript on every storefront page — for analytics, cart functionality, customer accounts, and the checkout. These scripts total 100-200KB and cannot be removed or deferred without breaking core functionality.
How to Find Unused CSS & JavaScript on Your Shopify Store
Before removing anything, you need to identify what's unused and where it comes from. Chrome's Coverage tool is the best free option.
Step 1: Open Chrome DevTools Coverage
- Open your store in Chrome
- Press F12 (or Cmd+Option+I on Mac) to open DevTools
- Press Ctrl+Shift+P (Cmd+Shift+P on Mac) to open the command palette
- Type "Coverage" and select "Show Coverage"
- Click the reload button (⟳) in the Coverage panel
- Wait for the page to fully load
Step 2: Read the Results
The Coverage panel shows every CSS and JS file with a red/green bar:
- Green = code that was executed/applied on this page
- Red = code that was loaded but never used on this page
- Total Bytes = full file size
- Unused Bytes = wasted bandwidth that blocks rendering
Click any file to see line-by-line usage. Red lines are unused CSS rules or JavaScript functions. For a typical Shopify store, you'll see:
base.cssortheme.css— 50-70% unused (theme global styles)vendor.jsortheme.js— 40-60% unused (theme JavaScript)- App-specific files — 70-90% unused per page (most app code isn't needed)
- Shopify's own scripts — 30-50% unused (core platform code)
Step 3: Identify the Biggest Offenders
Sort by "Unused Bytes" (click the column header). The files with the most unused bytes are your highest-impact targets. Typically: theme CSS, 1-2 large app bundles, and Shopify's analytics scripts. For the JavaScript side specifically, our JavaScript optimization guide covers deeper analysis.
What Unused Code You Can Actually Remove on Shopify
Let's be realistic: you can't eliminate all unused CSS/JS on Shopify. But you can make meaningful reductions. Here's what's actionable:
✅ Removable: Orphaned App Code
This is the easiest and safest cleanup. Search your theme for code left behind by uninstalled apps:
- Go to Online Store → Themes → Edit Code
- Open theme.liquid (or layout/theme.liquid)
- Search for
<scripttags loading from external domains you don't recognize - Check the snippets/ folder for files named after apps you no longer use
- Search all files for the app's name (e.g., search "loox" or "klaviyo" if you uninstalled those)
- Remove the identified code blocks and test your store thoroughly
Always backup your theme first. Duplicate the theme before editing, so you can revert if something breaks.
✅ Removable: Unused Theme Features
Many themes include code for features you might not use. Check if your theme has toggleable features you've disabled — some themes load the CSS/JS even when disabled. Common candidates:
- Quick view / quick add to cart modal (if disabled, check if CSS/JS still loads)
- Built-in product reviews (if using an app instead)
- Color swatch generators (if not using variant swatches)
- Built-in newsletter popup (if using an app instead)
- Product zoom / lightbox (if disabled)
⚠️ Partially Addressable: Conditional Loading
You can use Liquid conditionals to load code only on specific templates. This doesn't remove unused code — it prevents it from loading on irrelevant pages:
{% comment %} Only load review CSS on product pages {% endcomment %}
{% if template contains 'product' %}
{{ 'review-styles.css' | asset_url | stylesheet_tag }}
{% endif %}
{% comment %} Only load collection JS on collection pages {% endcomment %}
{% if template contains 'collection' %}
<script src="{{ 'collection-filters.js' | asset_url }}" defer></script>
{% endif %} This works for your theme code. App-injected code can't be conditionally loaded this way because apps control their own injection.
❌ Not Removable: Core Shopify & Active App Code
These sources of unused code can't be removed, only deferred:
- Shopify's core scripts — analytics, checkout, cart, customer accounts
- Active app CSS/JS — you can't modify code injected by installed apps
- Theme global CSS — without a full theme rewrite with code splitting, the global stylesheet loads everywhere
- Shopify's analytics — required for Shopify's own dashboard and reporting
This is where deferring beats removing. Thunder defers these non-critical resources so they load after the page renders — reducing render-blocking without removing functionality.
Why Deferring Beats Removing for Shopify Unused Code
On a static site, removing unused CSS is straightforward — each page has known, fixed content. On Shopify, it's dangerous because:
- Dynamic content — Liquid templates add CSS classes conditionally. A product with 5 variants loads different CSS than one with 2. PurgeCSS can't detect Liquid-generated classes.
- JavaScript-added elements — cart drawers, quick view modals, and AJAX add-to-cart create DOM elements dynamically. Their CSS looks "unused" until user interaction triggers them.
- Cross-page dependencies — CSS that's unused on your homepage is critical on your product page. Removing it from the global stylesheet breaks other pages.
- App updates — apps can change their CSS class names in updates. If you've purged their "unused" CSS, the update breaks the styling.
Deferring is the safe alternative. Deferred CSS/JS still loads and works — it just loads after the page renders instead of blocking it. The visitor sees the page faster, all functionality still works, and nothing breaks on updates.
This is exactly what Thunder does with render-blocking resources. It identifies which CSS and JavaScript isn't needed for the initial paint and defers it, while inlining the critical CSS needed for above-the-fold content.
Step-by-Step: Clean Up Orphaned App Code
This is the one cleanup you should do manually — it's free, safe, and gives immediate results. Here's how to find and remove code from apps you've uninstalled:
- Backup your theme — Go to Online Store → Themes → Actions → Duplicate. Always have a fallback.
- List your current apps — Go to Settings → Apps and sales channels. Note every installed app.
- Open the theme editor — Go to Online Store → Themes → Edit Code.
- Check theme.liquid — Open
layout/theme.liquidand look for<script>tags and<link>tags that reference external domains. If you see a domain that doesn't match any installed app, it's likely orphaned code. - Check snippets/ — Browse the snippets folder. Files with app names (e.g.,
bold-options.liquid,loox-reviews.liquid) that don't match installed apps are orphaned. Delete them and remove the corresponding{% render %}or{% include %}calls. - Search for known patterns — Use the code editor search (Ctrl+F) across all files for:
- App names you previously used
ScriptTagreferences- External domains in script
srcattributes
- Test thoroughly — Preview the theme, test add-to-cart, checkout flow, and all page types before publishing.
Common cleanup wins: removed review app snippets (50-100KB), old analytics scripts (20-50KB), and abandoned popup/banner code (30-80KB). Not huge individually, but cumulatively significant. For a full theme audit, see our Shopify speed audit guide.
⚡ Manual Cleanup vs Thunder: Reducing Unused Code Impact
| Approach | What It Fixes | Effort | Risk |
|---|---|---|---|
| Remove orphaned app code | Dead code from uninstalled apps | 1-2 hours (manual) | Low (if backed up) |
| Conditional Liquid loading | Page-specific theme CSS/JS | 2-4 hours (developer) | Medium |
| CSS purging (PurgeCSS) | Unused theme CSS rules | 4-8 hours (senior dev) | High (breaks things) |
| Thunder (defer everything) | All render-blocking CSS/JS | 60 seconds | Zero (reversible) |
Best approach: Remove orphaned code manually (free wins), then install Thunder to defer everything else. Plans start at $19.99/mo with a free trial.
Realistic Expectations: How Much Can You Reduce?
The "Reduce unused CSS/JS" warning in PageSpeed Insights will never fully disappear on a Shopify store. Here's what's realistic:
| Action | Unused Code Reduction | Speed Improvement |
|---|---|---|
| Remove orphaned app code | 50-200KB removed entirely | 100-300ms faster |
| Conditional Liquid loading | 20-50% less per page | 50-200ms faster |
| Thunder (defer non-critical) | 60-80% less render-blocking | 500ms-2s faster first paint |
| Remove unused apps | 100-500KB per app removed | 200-500ms per app |
The highest-impact move is almost always removing apps you don't actively need. Each app removal eliminates both its code and its HTTP requests. For a deep dive into optimizing your remaining JavaScript, see our JavaScript optimization guide. For CSS specifically, our CSS optimization guide covers critical CSS, minification, and advanced techniques.
Frequently Asked Questions
Why does PageSpeed Insights say 'Reduce unused CSS' on my Shopify store?
Shopify themes load a single global CSS file on every page — but each page only uses 30-50% of that CSS. A product page doesn't need collection grid styles, and a homepage doesn't need checkout CSS. Additionally, every installed app injects its own CSS bundle globally, even on pages where the app isn't active. PageSpeed Insights flags the unused portion because the browser must download and parse all CSS before rendering anything — unused CSS directly delays first paint.
Can I completely remove unused CSS and JavaScript on Shopify?
No — not completely. Shopify's architecture loads theme CSS and certain core scripts globally. You can't split Shopify's theme CSS into page-specific bundles without extensive custom development. App CSS and JS are injected by the apps themselves, and you can't modify them. However, you can: (1) remove orphaned code from uninstalled apps, (2) conditionally load page-specific Liquid snippets, (3) defer non-critical CSS/JS so it doesn't block rendering, and (4) use Thunder to automatically defer unused resources.
How do I find which CSS is unused on my Shopify store?
Open Chrome DevTools (F12), press Ctrl+Shift+P (Cmd+Shift+P on Mac), type 'Coverage', and select 'Show Coverage'. Click the reload button. You'll see a list of CSS and JS files with red (unused) and green (used) bars. Click any file to see line-by-line usage. Typical Shopify stores show 60-80% unused CSS on any single page. Important: CSS flagged as 'unused' on one page may be needed on other pages, so don't blindly delete all red lines.
Do uninstalled Shopify apps leave behind code?
Yes — this is one of the most common sources of unused code. When you uninstall a Shopify app, it removes its backend functionality but often leaves behind code snippets injected into your theme. Check theme.liquid, snippets/, and sections/ for code referencing the uninstalled app. Common signs: script tags loading from domains you don't recognize, Liquid snippets named after apps you no longer use, and inline styles or CSS links that reference removed apps. Removing this orphaned code is the easiest performance win.
Should I use PurgeCSS or a CSS removal tool on my Shopify store?
Be very careful. Automated CSS purging tools like PurgeCSS work well for static sites but are risky for Shopify because: (1) Shopify uses dynamic Liquid templates that add classes conditionally, which purge tools can't detect, (2) App-injected CSS references classes that don't exist in your theme files, (3) Cart drawer, quick view, and AJAX features add DOM elements dynamically. If you purge CSS aggressively, you'll likely break your cart, product quick-view, or app functionality. Deferring unused CSS (loading it after first paint) is safer than removing it.
What's the difference between removing and deferring unused CSS/JS?
Removing means deleting the code entirely — it never loads. This saves bandwidth but risks breaking functionality if the code was actually needed. Deferring means the code still loads, but after the page renders — it doesn't block first paint. Deferring is safer because all functionality still works; it just loads later. For Shopify stores, deferring is usually the better approach since you can't always know which CSS/JS rules are needed across all pages and user interactions. Thunder defers non-critical CSS and JavaScript automatically.
Stop Unused Code from Slowing Your Shopify Store
You can't eliminate unused CSS and JavaScript on Shopify entirely — the platform's architecture loads global styles and scripts by design. But you can make a meaningful difference with three steps: clean up orphaned app code (free, immediate), reduce installed apps to only what you need (free, high impact), and defer everything else with Thunder Page Speed Optimizer (60 seconds, highest impact).
The "Reduce unused CSS/JS" warnings in PageSpeed Insights may never fully disappear. That's normal for Shopify. Focus on the real metrics: LCP under 2.5 seconds, CLS under 0.1, and fast perceived loading.
Test your store now and check how much unused code is blocking your render. For the full speed optimization strategy, see our complete Shopify speed optimization guide.
Expert Speed Optimization for Your Store
Our team handles everything — theme optimization, app cleanup, Core Web Vitals guarantee. Most stores optimized in 2 weeks.
✅ Core Web Vitals Guarantee · ⚡ 2-Week Delivery · 🎁 6 Months Free Thunder
Starting from €1,500 · Learn more