Created
February 12, 2018 12:37
-
-
Save mrfoxtalbot/891fb3413fac95c3d8bed5a0ea725d94 to your computer and use it in GitHub Desktop.
Remove Contact Form 7 Scripts and Stlyes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//You can set the value of this constant in your wp-config.php like this: | |
define('WPCF7_LOAD_JS', false); | |
//Likewise, you can control the loading of the CSS stylesheet with WPCF7_LOAD_CSS. Contact Form 7 does not load the CSS stylesheet when the value of WPCF7_LOAD_CSS is false (default: true). You can set it in the wp-config.php like this: | |
define('WPCF7_LOAD_CSS', false); | |
//Or, you can also disable the loading of the JavaScript and CSS by adding a few lines of code into your theme’s functions.php file, like this: | |
add_filter( 'wpcf7_load_js', '__return_false' ); | |
add_filter( 'wpcf7_load_css', '__return_false' ); | |
// And then load it only where the form is used. | |
// Note that wpcf7_enqueue_scripts() and wpcf7_enqueue_styles() must be called before wp_head() is called. | |
if ( function_exists( 'wpcf7_enqueue_scripts' ) ) { | |
wpcf7_enqueue_scripts(); | |
} | |
if ( function_exists( 'wpcf7_enqueue_styles' ) ) { | |
wpcf7_enqueue_styles(); | |
} | |
// source: https://contactform7.com/loading-javascript-and-stylesheet-only-when-it-is-necessary/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment