Skip to content

Instantly share code, notes, and snippets.

@scottlyttle
Last active December 20, 2015 05:19
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 scottlyttle/6077661 to your computer and use it in GitHub Desktop.
Save scottlyttle/6077661 to your computer and use it in GitHub Desktop.
Deregister scripts and styles on pages they're not needed (WordPress)
add_action( 'wp_enqueue_scripts', 'deregister_cf7_javascript', 15 );
function deregister_cf7_javascript() {
if ( !is_page(15) ) {
wp_deregister_script( 'contact-form-7' );
}
}
add_action( 'wp_enqueue_styles', 'deregister_cf7_styles', 15 );
function deregister_cf7_styles() {
if ( !is_page(15) ) {
wp_deregister_style( 'contact-form-7' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment