Not all gravity form scripts are moving to footer

enter image description here

Hello I am using the gravity form plugin, and I am moving the scripts to the footer using this code:

// GF method: http://www.gravityhelp.com/documentation/gravity-forms/extending-gravity-forms/hooks/filters/gform_init_scripts_footer/
add_filter( 'gform_init_scripts_footer', '__return_true' );

// solution to move remaining JS from https://bjornjohansen.no/load-gravity-forms-js-in-footer
add_filter( 'gform_cdata_open', 'wrap_gform_cdata_open' );
function wrap_gform_cdata_open( $content = '' ) {
    $content = 'document.addEventListener( "DOMContentLoaded", function() { ';
    return $content;
}
add_filter( 'gform_cdata_close', 'wrap_gform_cdata_close' );
function wrap_gform_cdata_close( $content = '' ) {
    $content = ' }, false );';
    return $content;
}

It seems to work, two gravity form scripts are in the footer, but there is still one pesky script loading in the middle of my page. Here is a screenshot:

I did some digging and found that the script is being created in formdisplay.php on line 1046.

Any ideas on how to inject this thing into the footer?

Thanks!

Read more here:: Not all gravity form scripts are moving to footer

Leave a Reply

Your email address will not be published. Required fields are marked *