Docs    

Only include the plugin files on specific pages

By default the Smash Balloon plugins will include its CSS and in some cases JavaScript file on every page, as, due to browser caching, once the files are loaded once by the user then they will be cached for every subsequent page load.  Nonetheless, you can choose to only include the plugin CSS and JavaScript files only on specific pages by adding the following to your theme’s functions.php file:

add_action( 'wp_enqueue_scripts', 'remove_cff_resources', 20 );
function remove_cff_resources() { 
    if( !is_page(array( 'news', 'blog' )) ){
        wp_dequeue_style('cff'); 
        wp_dequeue_script('cffscripts'); 
    }
}

This will remove the plugin files on every page apart from pages with the slug or ‘news’ or ‘blog’. You can also specify the ID or page title instead of the slug. See here for examples of how to use the WordPress “is_page” function.

In a similar fashion, you can set the Instagram Feed plugin’s files to load only on the front page of your site with the following script to be placed in the functions.php file.

add_action( 'wp_enqueue_scripts', 'remove_sbi_resources', 20 );
function remove_sbi_resources() {
	if( !is_front_page() ){
	    wp_dequeue_style('sbi_styles');
	    wp_deregister_script('sbi_scripts');
	    wp_dequeue_script('sbi_scripts');
	}
}
support

Couldn’t find your answer in the docs?

Contact Support

Was this article helpful?