gform_force_hooks_js_output

Description

The gform_force_hooks_js_output filter can be used to prevent the Gravity Forms scripts from being injected into the pages if they’re not necessary.

Note: Enabling this filter may cause the server to use more memory. It is recommended that you monitor memory usage if you experience performance issues, particularly in cases where the Dom_Parser class is involved.

Usage

add_filter( 'gform_force_hooks_js_output', 'your_function_name' );

Parameters

Defaults to false. Set to true using the WordPress __return_true function or a custom function that returns true.

Examples

add_filter( 'gform_force_hooks_js_output', '__return_true' );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Since

This filter was added in Gravity Forms version 2.5.3.1.

Source Code

This filter is located in Gravity_Forms\Gravity_Forms\Libraries\Dom_Parser::get_injected_html() in includes/libraries/class-dom-parser.php and GFForms::localize_hook_vars() in gravityforms.php.