Disable Contact Form 7 JavaScript and CSS - function.php

PHOTO EMBED

Wed Aug 31 2022 21:35:11 GMT+0000 (UTC)

Saved by @satinbest

function rjs_lwp_contactform_css_js() {
    global $post;
    if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'contact-form-7') ) {
        wp_enqueue_script('contact-form-7');
         wp_enqueue_style('contact-form-7');

    }else{
        wp_dequeue_script( 'contact-form-7' );
        wp_dequeue_style( 'contact-form-7' );
    }
}
add_action( 'wp_enqueue_scripts', 'rjs_lwp_contactform_css_js');
content_copyCOPY

Disable Contact Form 7 JavaScript and CSS - bloat

https://stackoverflow.com/questions/48923540/remove-contact-form-7-css-and-js-unless-contact-form-7-shortcode-is-used-in-the