1 De-Registering Contact Form 7 CSS File
// Deregister Contact Form 7 styles
add_action( 'wp_print_styles', 'wdo_deregister_cf7_styles', 100 );
function wdo_deregister_cf7_styles() {
if ( ! is_page( 'contact-us' ) ) { // with use of WP conditional function load CF7 style only on those page where Form use, contact-us is slug of Contact page
wp_deregister_style( 'contact-form-7' );
}
}
// To De-Register CF7 css for front page
if ( is_front_page()) {
wp_deregister_style( 'contact-form-7' );
}
2 De-Registering Contact Form 7 JS File
// Deregister Contact Form 7 JavaScript files on all pages except Contac Us page
add_action( 'wp_print_scripts', 'wdo_deregister_cf7_javascript', 100 );
function wdo_deregister_cf7_javascript() {
if ( ! is_page( 'contact-us' ) ) {
wp_deregister_script( 'contact-form-7' );
}
}