Support » Plugin: Google Forms » Conditional script/style loading

  • I was wondering if it was possible to only enqueue the wpgform JS and CSS on the pages that contain the forms.

    I know with Contact form 7 you can add a hook like add_filter( ‘wpcf7_load_js’, ‘__return_false’ ); and then enqueue it when you want.

    Does wpgform have a hook like this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mike Walsh


    There isn’t right now but this is something I will look into. I had ventured down this path a while ago but can’t recall why I never implemented it. I agree that there is no need to load CSS or JS unless the rendered page has a form on it.

    Awesome, thanks so much!

    For anyone who is interested, I actually killed the 3 JS files being enqueued and it had no effect on my forms (for one that I’m using jquery-validate on I just enqueued it conditionally for that page) Here’s the function:

    function wpgform_dequeue_script() {
      wp_dequeue_script( 'jquery-columnizer' );
      wp_dequeue_script( 'wpgform-jquery-validate' );
      wp_dequeue_script( 'jquery-validate' );
    add_action( 'wp_print_scripts', 'wpgform_dequeue_script', 100 );

    Plugin Author Mike Walsh


    I have addressed this functionality to v0.73 of Google Forms. You can test it in the beta version available on my web site.

    Amazing, thanks Mike!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Conditional script/style loading’ is closed to new replies.