WooCommerce provides great functionality, but loads a lot of resources even if not needed.
If a site loads longer than 5-7 seconds, potential customers already loose interest :)
Add this to your functions.php:
add_action( 'wp_enqueue_scripts', 'cleanup_woocommerce_includes', 99 ); function cleanup_woocommerce_includes(){ //check that woo exists if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {} /*Styles*/ wp_dequeue_style( 'woocommerce_frontend_styles' ); wp_dequeue_style( 'woocommerce_fancybox_styles' ); wp_dequeue_style( 'woocommerce_chosen_styles' ); wp_dequeue_style( 'woocommerce_prettyPhoto_css' ); wp_dequeue_style( 'woocommerce-layout' ); wp_dequeue_style( 'woocommerce-smallscreen' ); wp_dequeue_style( 'woocommerce-general' ); wp_dequeue_style( 'wc-bto-styles' ); /*Scripts*/ wp_dequeue_script( 'wc-cart' ); wp_dequeue_script( 'wc-cart-fragments' ); wp_deregister_script( 'wc-add-to-cart' ); wp_dequeue_script( 'wc-add-to-cart' ); wp_deregister_script( 'wc-add-to-cart-variation' ); wp_dequeue_script( 'wc-add-to-cart-variation' ); wp_dequeue_script( 'wc-checkout' ); wp_dequeue_script( 'wc-single-product' ); wp_dequeue_script( 'jquery-blockui' ); wp_dequeue_script( 'wc_price_slider' ); wp_dequeue_script( 'wc-chosen' ); wp_dequeue_script( 'woocommerce' ); wp_dequeue_script( 'prettyPhoto' ); wp_dequeue_script( 'prettyPhoto-init' ); wp_dequeue_script( 'jquery-placeholder' ); wp_dequeue_script( 'fancybox' ); wp_dequeue_script( 'jqueryui' ); } } }
Like always, make sure that nothing breaks. If things break or are required by certain pages add an exception for that!
Check WordPress Condional Tags.
Sources:
remove_action('wp_head', 'wc_generator_tag');
What are particle animations? Particle network animations in JavaScript typically involve creating visual representations of… Read More
BOOKING SOLUTIONS 202x This is my take on a subset of booking, appointment, PMS or… Read More
THE GOAL Create a system cron for WordPress, that is accessible and can be easily… Read More
2024, what's cooking? Slowly getting into the 2024 spirit. 3 projects coming to a close… Read More
Short look back at 2023 This has been a busy and interesting year. I am… Read More
Elementor Pro provides grid containers as an experimental feature. The options provided are limited, when… Read More