HomeMethod

Knowledge

Web VitalsTechniquesSnippetsAnswersImpactsBottlenecks

WooCommerce loading on non-shop pages

  • Plugins & WordPress

Problem Summary

WooCommerce loads its scripts and styles on every page, even when not viewing shop pages. This adds unnecessary JavaScript and CSS to blog posts, pages, and non-ecommerce content.

Performance Impact

  • Render blocking: WooCommerce JS/CSS blocks rendering
  • Increased page size: Unnecessary assets on every page
  • Slow mobile: Extra weight hurts mobile users
  • Higher TTFB: More processing per request

How to Detect

  1. Chrome DevTools Network: WooCommerce files on non-shop pages

  2. PageSpeed Insights: Flags unused JavaScript
  3. GTmetrix: Shows WooCommerce resources everywhere

Solutions

1. Disable on Frontend

Code
<?php
add_action('wp_enqueue_scripts', function() {  if (!is_shop() && !is_product() && !is_cart() && !is_checkout()) {    wp_dequeue_style('woocommerce-layout');    wp_dequeue_style('woocommerce-smallscreen');    wp_dequeue_style('woocommerce-general');    wp_dequeue_script('wc-add-to-cart');    wp_dequeue_script('woocommerce');  }}, 99);

2. Use Plugin

WooCommerce Disable Cart / fragments, or Perfmatters.

3. Load Only Where Needed

Dequeue WooCommerce scripts conditionally.

Further Reading

Support our family now