Hi @snippet24,
Unfortunately there’s no way the plugin to know in advance which page includes a contact form, which is why the scripts load on every page. However, if you as the site owner know which pages the script is required on, you can quite easily take care of this manually.
You can add this to your functions.php. It will dequeue all the plugin scripts and styles except on pages with slug ‘contact’ or ‘form’. You will need to change the if
condition to suit your pages.
function my_dequeue_cf7md_assets() {
if( ! is_page( 'contact' ) && ! is_page( 'form' ) ) {
wp_dequeue_script( 'md-components-js' );
wp_dequeue_script( 'autosize' );
wp_dequeue_script( 'cf7-material-design' );
wp_dequeue_style( 'cf7md_roboto' );
wp_dequeue_style( 'cf7-material-design' );
}
}
add_action( 'wp_enqueue_scripts', 'my_dequeue_cf7md_assets', 20 );
There are some old threads that go into a bit more detail if you need further help. Here’s the most recent: https://www.ads-software.com/support/topic/prevent-scripts-from-loading-on-all-pages/
Thanks,
Angus