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

How to disable load plugin scripts on other pages except product page?

Olexandr P

I had successfully used code fragment in my functions.php to disable scripts load on all pages except product page:

add_action('wp_enqueue_scripts', function() {
if (!is_product()) {
add_filter('disable_wvg_enqueue_scripts', '__return_true');
}
});

Question is how to use this filters (code below), which hook must be used to make this filters working? How to use it properly?

add_filter('woo_variation_gallery_slider_template_js', '__return_empty_string');
add_filter('woo_variation_gallery_thumbnail_template_js', '__return_empty_string');

Ahmed Ehsaan

Hi Olexandr,

The first block of code is not correct. It should be like the following code.

add_action('init', function() {
if (!is_product()) {
add_filter('disable_wvg_enqueue_scripts', '__return_true');
}
});

Thank