Skip to content

Instantly share code, notes, and snippets.

@FreshLondon
Created August 12, 2020 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FreshLondon/7aa5c7ea78a16fe932761a2d9c83083b to your computer and use it in GitHub Desktop.
Save FreshLondon/7aa5c7ea78a16fe932761a2d9c83083b to your computer and use it in GitHub Desktop.
Only load WooCommerce scripts on shop pages/checkout/cart
if (!is_woocommerce() && !is_cart() && !is_checkout()) {
remove_action('wp_enqueue_scripts', [WC_Frontend_Scripts::class, 'load_scripts']);
remove_action('wp_print_scripts', [WC_Frontend_Scripts::class, 'localize_printed_scripts'], 5);
remove_action('wp_print_footer_scripts', [WC_Frontend_Scripts::class, 'localize_printed_scripts'], 5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment