如何将Ajax Gravity Form的嵌入式jQuery脚本移动到页脚?

问题描述 投票:0回答:1

为了将延期添加到jquery链接,我想将Ajax Gravity Form的嵌入式jQuery脚本移至页脚。

我该怎么办?

enter image description here

wordpress jquery-deferred gravity-forms-plugin critical-css
1个回答
0
投票

这可能有效:

/**
 * Force GFORM Scripts inline next to Form Output
 *
 * force the script tags inline next to the form. This allows
 * us to regex them out each time the form is rendered.
 * 
 * see strip_inline_gform_scripts() function below
 * which implements the required regex
 */
add_filter("gform_init_scripts_footer", "__return_false");

/**
 * Strip out GForm Script tags
 *
 * note: this diables post and pre render hooks which are triggered
 * when the form renders so if you need these then it's important
 * to manually re-add them in your compiled JS source code
 */

add_filter("gform_get_form_filter", function( $form_string, $form ) {
  return $form_string = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $form_string);
}, 10, 2);
© www.soinside.com 2019 - 2024. All rights reserved.