Skip to content

Instantly share code, notes, and snippets.

@tayvano
Forked from eriteric/movegfjstofooter.php
Last active June 17, 2017 04:45
Show Gist options
  • Select an option

  • Save tayvano/1ef1e37f503597e6165fdfeb25b14aa8 to your computer and use it in GitHub Desktop.

Select an option

Save tayvano/1ef1e37f503597e6165fdfeb25b14aa8 to your computer and use it in GitHub Desktop.

Revisions

  1. tayvano renamed this gist Jun 17, 2017. 1 changed file with 11 additions and 7 deletions.
    18 changes: 11 additions & 7 deletions movegfjstofooter.php → gforms-to-footer.php
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,18 @@
    // 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' );

    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;
    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;
    function wrap_gform_cdata_close( $content = '' ) {
    $content = ' }, false );';
    return $content;
    }
  2. eriteric renamed this gist Mar 17, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. 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;
    }