[Broken] Loading JavaScript and Stylesheet Only When it is Necessary
-
I had previously followed the advice in this post
https://contactform7.com/loading-javascript-and-stylesheet-only-when-it-is-necessary/ and everything was working just dandy.However, I updated to the latest release of the Contact Form 7 plugin and there has been a code changes to contact-form-7/includes/controller.php
function wpcf7_enqueue_scripts() { if ( ! wpcf7_load_js() ) { // this test was added return; } function wpcf7_enqueue_styles() { if ( ! wpcf7_load_css() ) { // this test was added return; }
Which means the logic previously applied in wp-config.php to delay loading JavaScript and stylesheets no longer works. If you have the two variables defined in wp-config.php (as described in the link above):
define( 'WPCF7_LOAD_JS', false ); define( 'WPCF7_LOAD_CSS', false );
Then even if you modify your template files to manually call the functions wpcf7_enqueue_scripts() and wpcf7_enqueue_styles(), before wp_head() is called, the functions just ‘return’ without loading the necessary JavaScript and Stylesheet files…
But maybe I’m missing something here… are other people experiencing the same issue?
Thanks in advance.
- The topic ‘[Broken] Loading JavaScript and Stylesheet Only When it is Necessary’ is closed to new replies.