I have this which woks, but would appreciate an ‘official’ alternative.
// Dequeue the Slider stylesheet, except front page
add_action( 'wp_print_styles', function() {
// if we are on front page, abort.
if ( is_front_page() ) {
return;
}
wp_dequeue_style( 'seo-slider' );
}, 100 );
and;
// Dequeue the Slider script, except front page
add_action( 'wp_print_scripts', function() {
// if we are on front page, abort.
if ( is_front_page() ) {
return;
}
wp_dequeue_script( 'seo-slider' );
}, 100 );
-
This reply was modified 6 years, 11 months ago by
darrencss.
-
This reply was modified 6 years, 11 months ago by
darrencss.
@darrencss It’s not possible to tell which pages have a slider and which ones don’t. It is possible to check which pages have a slider in the content but that doesn’t include widget areas.
Your solution will work, you could also do the following:
if ( ! is_front_page() ) {
remove_action( 'wp_enqueue_scripts', 'seo_slider_scripts_styles' );
}
Thanks for the response, however, I have found excluding the code causes problems with other plugins.
As a consequence I have simply removed the slider. It looks like the most ‘seo-friendly’ slider is actually no slider at all.
@darrencss there might have been an error in your code somewhere.
I can’t see how removing the plugins assets could possibly affect other plugins?