fbpx
Want To Add Extra Images Per Product Variation For Free? Download Now

Remove Unnecessary Files

ELROY MYERS

Hello Our Website is https://www.nakmuaywholesale.com/

 

We use the Woo Variable Switcher Pro plugin on our website, and we believe it only needs to work on the product pages. However, it is unnecessarily adding files to the home, archive, and single pages or posts, which we don’t need.

Is there a way to remove these unnecessary files? Alternatively, could you help identify which files are responsible for adding the CSS and JS? This way, we can edit the plugin to add checks (e.g., is_single(), is_front_page()) to conditionally enqueue these files only where needed.

Best regards.

css js.png

Hakik Zaman

Hi ELROY,

Thanks for reaching out to us.

You can try the following snippet inside your current theme’s functions.php file-

add_action('wp_enqueue_scripts', function(){
if( is_archive() || is_front_page() ){
wp_deregister_script( 'woo-variation-swatches' );
wp_deregister_style( 'woo-variation-swatches' );
}
}, 99);

Note: It is recommended to add the Custom Code to the child theme’s functions.php file, to avoid any data loss while updating the Parent Theme.

Hope to hear from you soon.

Thank You

Hakik Zaman

Hi ELROY,

Please replace the previous snippet with the following:

add_action('wp_enqueue_scripts', function(){
if( is_archive() || is_front_page() ){
wp_deregister_script( 'woo-variation-swatches' );
wp_deregister_style( 'woo-variation-swatches' );
wp_deregister_script( 'wc-add-to-cart-variation' );

}
}, 99);

Thanks