Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter darrencss

    (@darrencss)

    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 5 years, 10 months ago by darrencss.
    • This reply was modified 5 years, 10 months ago by darrencss.
    Plugin Author seothemes

    (@seothemes)

    @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' );
    }
    
    Thread Starter darrencss

    (@darrencss)

    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.

    Plugin Author seothemes

    (@seothemes)

    @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?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Disable scripts and css on other pages’ is closed to new replies.