# Load WooCommerce Assets Only on Shop Pages

> Stops WooCommerce stylesheets and scripts from loading on pages that are not part of the store, such as blog posts and the about page.

- Type: PHP
- Runs: Frontend only
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, performance, scripts, css
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-assets-only-on-shop-pages/

## Code

```php
add_action( 'wp_enqueue_scripts', function () {
    if ( ! function_exists( 'is_woocommerce' ) ) {
        return;
    }

    if ( is_woocommerce() || is_cart() || is_checkout() || is_account_page() ) {
        return;
    }

    foreach ( array( 'woocommerce-general', 'woocommerce-layout', 'woocommerce-smallscreen' ) as $handle ) {
        wp_dequeue_style( $handle );
    }

    foreach ( array( 'wc-cart-fragments', 'woocommerce', 'wc-add-to-cart' ) as $handle ) {
        wp_dequeue_script( $handle );
    }
}, 99 );
```

## Notes

Do not use this if non-shop pages show products, a mini cart or add-to-cart buttons.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Load WooCommerce Assets Only on Shop Pages" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
