Can’t dequeue CF7 files
-
Hi,
as ReCaptcha 3 is breaking my Google Page Speed score, I’m trying to dequeue both Contact Form and ReCaptcha external files from all pages but contact page.
I followed the instructions of this page : https://contactform7.com/loading-javascript-and-stylesheet-only-when-it-is-necessary/But I doesn’t work. Files are still included in my source code :
https://www.google.com/recaptcha/api.js?render=6LcSosUZAAAAAFR-VBlVWx5MFd9zrhuIgwVD5-vY&ver=3.0
/wp-content/plugins/contact-form-7/modules/recaptcha/script.js?ver=5.2.2I use WordPress 5.5 and Contact Form 5.2.2
I don’t use any caching plugin.Here’s my functions.php file :
function wpdocs_dequeue_script() { add_filter( 'wpcf7_load_js', '__return_false' ); add_filter( 'wpcf7_load_css', '__return_false' ); wp_dequeue_script('contact-form-7'); wp_dequeue_style('contact-form-7'); wp_deregister_script('jquery'); // remove jquery which is manually included in footer.php } add_action( 'wp_print_scripts', 'wpdocs_dequeue_script', 100 );
There lines return a critical error :
wpcf7_dequeue_scripts(); wpcf7_dequeue_styles();
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Can’t dequeue CF7 files’ is closed to new replies.