Remove unused GF script from header [RESOLVED]

Hi,

I think GF 2.5 started adding a script to the very first line in the header that starts “if(!gform){document.addEventListener(“gform_main_scripts_loaded”,function(){gform.scriptsLoaded…”.

This script is placed on every page, regardless of whether there is a form on the page or not.
In a time of core web vitals, I would like to display this script only where it is really needed.

How can I achieve this? Or is it really needed on every page?
Thanks!

2 Likes

I have the same problem. Additionally this script is added before charset attribute in the theme and it’s causing an error on W3C validation. “Error : A charset attribute on a meta element found after the first 1024 bytes.”

Thanks!

The Product team are aware of this issue and are working on a fix, but none has been made available yet. I recommend contacting support https://www.gravityforms.com/support/ if you need any additional information. Thank you.

Please try updating to the latest build, available from the downloads page, following the steps at https://docs.gravityforms.com/how-to-manually-update/

Once updated you’ll also need to clear/flush any caching and/or script optimization plugins and/or services the site is using as well as your browser cache.

1 Like