Skip to main content
100%

Remove WooCommerce related resources except on WooCommerce-based pages (products, cart, checkout, etc). Use on a testing environment before pasting this into your live website!

✓ Published0🌍 Public
CChrisb4
Last edited Feb 28, 2020
Created on May 21, 2020

This code sample demonstrates how to selectively disable WooCommerce stylesheets and scripts on non-WooCommerce pages using WordPress PHP hooks. It shows a site optimization technique that checks for WooCommerce-specific conditions before dequeuing assets. The implementation uses the `wp_enqueue_scripts` action hook and WooCommerce conditionals like `is_woocommerce()`, `is_cart()`, and `is_checkout()` to determine page context, then removes targeted handles such as `woocommerce-general`, `wc-cart-fragments`, and `jquery-blockui`. The code runs on a testing environment before deployment to production.

AI-generated description

Similar vizzes