Skip to content

Instantly share code, notes, and snippets.

@eriteric
Last active December 27, 2024 20:31

Revisions

  1. eriteric renamed this gist Mar 17, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. eriteric created this gist Mar 17, 2015.
    14 changes: 14 additions & 0 deletions movegfjstofooter
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    // 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;
    }