loading javascript and stylesheet only when it is necessary/
-
The CSS and JS loads for all Contact Form 7 forms, what is the best way to have the plugin CSS and JS only load for specific forms/pages just like Contact Form 7 does at https://contactform7.com/loading-javascript-and-stylesheet-only-when-it-is-necessary/
/* Dequeue Scripts and Styles START */
function disable_scripts_styles() {
// if this is not the page, remove the script
if( ! is_page(‘page-name’) ){
wp_dequeue_style(‘dnd-upload-cf7-css’);wp_dequeue_script(‘codedropz-uploader-js’);
wp_dequeue_script(‘dnd-upload-cf7-js-extra’);
wp_dequeue_script(‘dnd-upload-cf7-js’);}
}// adjust priority to make sure this runs after the plugins add their scripts/styles
add_action(‘wp_enqueue_scripts’,’disable_scripts_styles’, 100);
/* Dequeue Scripts and Styles END */Using a similar logic one could use this?
remove_action( ‘wpcf7_enqueue_scripts’, ‘dnd_cf7_scripts’, 10 );
Neither of these 2 examples seem to work. Any help/pointers will be appreciated. Thanks!
The page I need help with: [log in to see the link]
- The topic ‘loading javascript and stylesheet only when it is necessary/’ is closed to new replies.