A blog post on a WooCommerce site often ships the shop’s CSS and JavaScript to readers who will never see a product. It isn’t much per file, but it is on almost every visit, and it is work the browser has to do before the page settles. On content-heavy stores, that is most of your traffic.
This guide shows what WooCommerce actually loads (checked against WooCommerce 11.3), what is safe to remove, and how to do it without breaking checkout.
What WooCommerce loads on every page
Open any non-shop page, view the source and search for woocommerce. On a typical site you will find these:
| File | Every page | Only where needed |
|---|---|---|
woocommerce-general, -layout, -smallscreen (classic themes) | Yes | No |
woocommerce-blocktheme (block themes) | Yes | No |
woocommerce (woocommerce.js) | Yes | No |
wc-add-to-cart (when AJAX add to cart is on) | Yes | No |
sourcebuster-js + wc-order-attribution | Yes | No |
wc-cart-fragments | No | Only with the Cart widget |
wc-cart, wc-checkout, wc-single-product | No | Yes |
The good news: WooCommerce already keeps the heavy cart, checkout and product-gallery scripts to the pages that use them, and since WooCommerce 7.8 the cart fragments script only loads where the classic Cart widget is used. What is left on every page is the main stylesheets, woocommerce.js and the add-to-cart script.
Open your browser’s developer tools, go to the Network tab, reload a blog post and filter by woocommerce. Note the number of requests and their size. You will compare against this at the end.
Before you start
- A way to add PHP snippetsA child theme’s functions.php, a must-use plugin or a code snippets plugin
- A backup or staging siteSo you can test checkout safely
- A list of pages that sellIncluding landing pages with product blocks or shortcodes
Remove WooCommerce files from pages that don’t sell
Add the snippet
This snippet from our library runs after WooCommerce has queued its files. On shop, product, category, cart, checkout and account pages, and on any page with WooCommerce blocks or product shortcodes, it changes nothing. Everywhere else it removes the stylesheets, block styles and the add-to-cart and cart fragments scripts.
It checks that WooCommerce is active first, so deactivating WooCommerce later won’t take your site down.
Leave order attribution alone
sourcebuster-jsandwc-order-attributionlook like the kind of script you would remove, but they record which page and campaign a visitor arrived from. If a reader lands on a blog post and buys later, WooCommerce only knows the post sent them because those scripts ran on it. The snippet keeps them on purpose.Don't use order attribution at all?Turn it off properly instead of removing the scripts: WooCommerce → Settings → Advanced → Features, then untick Order attribution. WooCommerce then stops loading both scripts everywhere.
Theme styles WooCommerce itself? Turn its CSS off everywhere
Some themes, and most page builders, ship their own complete WooCommerce styling. In that case WooCommerce’s stylesheets are only overridden, never used, and you can switch them off on every page:
// Only if your theme styles the shop, cart and checkout itself. add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );Tested on WordPress 7.1 · PHP 8.3Check the shop, a product, the cart and checkout afterwards. If buttons or the checkout form look broken, your theme relies on WooCommerce’s CSS: remove this line and use only the snippet above.
On a blog post, the Network tab no longer lists woocommerce-general, woocommerce-layout or wc-add-to-cart. On the shop, product pages, cart and checkout, everything still loads and works.
Something broke after adding the snippet3 common fixes
- The mini-cart count in the header is wrong on blog posts. It updates through cart fragments. Either accept the count from page load, or add the pages with a mini-cart to the snippet’s list of store pages.
- A landing page with a product grid looks unstyled. Products added through a template part, such as the footer, aren’t detected. Add that page’s check to the snippet.
- Add to cart does nothing on a custom page. The page sells, so it needs the scripts. Add it to the store pages in the snippet.
The three pages you must never strip
Whatever you change, the cart, checkout and My Account pages need every WooCommerce file. They validate addresses, update totals, take payments and handle logins with that JavaScript. The snippet already leaves them alone. If you write your own version, start from is_cart() || is_checkout() || is_account_page() and return early.
Check the result
Run the same test as at the start: reload a blog post with the Network tab open and filter by woocommerce. You should see fewer requests and a smaller total. Then place a test order from a product page to the thank-you page, so you know the store side is untouched.
If you use a page cache, clear it first, or you will be measuring the old page.
Check your understanding
Was this helpful?
Sorry about that. What was missing?
Thanks for your feedback!

