Skip to content

Instantly share code, notes, and snippets.

@palpalani
Created December 27, 2014 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save palpalani/6f43ae96a51ffdb3cac4 to your computer and use it in GitHub Desktop.
Save palpalani/6f43ae96a51ffdb3cac4 to your computer and use it in GitHub Desktop.
WordPress - Contact 7 form - load js, css only needed pages
<?php
/*
Contact 7 form - load js, css only needed pages
*/
add_action( 'wp_print_scripts', 'deregister_cf7_javascript', 100 );
function deregister_cf7_javascript() {
if ( !is_page(array(8, 10)) ) {
wp_deregister_script( 'contact-form-7' );
}
}
add_action( 'wp_print_styles', 'deregister_cf7_styles', 100 );
function deregister_cf7_styles() {
if ( !is_page(array(8, 10)) ) {
wp_deregister_style( 'contact-form-7' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment