gform_load_admin_scripts_globally

Description

Gravity Forms now loads our new JavaScript bundles that were introduced in 2.5 across all admin screens. We have done this since we are using code splitting to dynamically inject JavaScript as it is needed. Due to this we can minimize any performance impact while making our scripts and libraries available to add-ons or third party integrations in the WordPress admin with ease. This also better prepares Gravity Forms for full site editing.

This filter can be used to prevent global loading of scripts. Note that doing so may cause feature loss in some add-ons or Gravity Forms core.

Usage

The following would apply to all forms.

add_filter( 'gform_load_admin_scripts_globally', 'your_functions_name' );

Parameters

  • $load_scripts bool
    Load admin scripts globally? Default is true.

Examples

1. Disable global admin script loading

add_filter( 'gform_load_admin_scripts_globally', function() { return false; } );

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 2.6.

Source Code

This filter is located in GFForms::enqueue_admin_scripts() and GFForms::no_conflict_mode_script() in gravityforms.php.