alejomejia
2/1/2018 - 12:34 PM

Deregister Contact Form 7 CSS and JS

Deregister Contact Form 7 styles and code from pages where it is not active.

add_action( 'wp_print_styles', 'deregister_styles', 100 );

function deregister_styles() {
  if ( ! is_page( array( 7646, 7659, 7652, 7739, 7734, 7730 ) ) ) {
    wp_deregister_style( 'contact-form-7' );
  }
}

add_action( 'wp_print_scripts', deregister_javascript', 100 );

function deregister_javascript() {
  if ( ! is_page( array( 7646, 7659, 7652, 7739, 7734, 7730 ) ) ) {
    wp_deregister_script( 'contact-form-7' );
  }
}