Gravity Forms Injecting Inline Javascript Code in Header | Fix or Input Needed

Good Day!

On every page where we use Gravity Forms, we noticed Gravity Forms is placing an inline Javascript code in the header of our affected pages (ahead of other, more important code).

Details:

Code Excerpt:

<script type="text/javascript">
var gform;gform||(document.addEventListener("gform_main_scripts_loaded",function(){gform.scriptsLoaded=!0}),window.addEventListener("DOMContentLoaded",function(){gform.domLoaded=!0}),gform={domLoaded:!1,scriptsLoaded:!1,initializeOnLoaded:function(o){gform.domLoaded&&gform.scriptsLoaded?o():!gform.domLoaded&&gform.scriptsLoaded?window.addEventListener("DOMContentLoaded",o):document.addEventListener("gform_main_scripts_loaded",o)},hooks:{action:{},filter:{}},addAction:function(o,n,r,t){gform.addHook("action",o,n,r,t)},addFilter:function(o,n,r,t){gform.addHook("filter",o,n,r,t)},doAction:function(o){gform.doHook("action",o,arguments)},applyFilters:function(o){return gform.doHook("filter",o,arguments)},removeAction:function(o,n){gform.removeHook("action",o,n)},removeFilter:function(o,n,r){gform.removeHook("filter",o,n,r)},addHook:function(o,n,r,t,i){null==gform.hooks[o][n]&&(gform.hooks[o][n]=[]);var e=gform.hooks[o][n];null==i&&(i=n+"_"+e.length),gform.hooks[o][n].push({tag:i,callable:r,priority:t=null==t?10:t})},doHook:function(n,o,r){var t;if(r=Array.prototype.slice.call(r,1),null!=gform.hooks[n][o]&&((o=gform.hooks[n][o]).sort(function(o,n){return o.priority-n.priority}),o.forEach(function(o){"function"!=typeof(t=o.callable)&&(t=window[t]),"action"==n?t.apply(null,r):r[0]=t.apply(null,r)})),"filter"==n)return r[0]},removeHook:function(o,n,t,i){var r;null!=gform.hooks[o][n]&&(r=(r=gform.hooks[o][n]).filter(function(o,n,r){return!!(null!=i&&i!=o.tag||null!=t&&t!=o.priority)}),gform.hooks[o][n]=r)}});
</script>

Questions:

(1) What is the purpose of this inline JS code and why is it loaded in the header? (I’m not a coder nor a developer)

(2) How can I delay, defer, or move this code to the the footer of our website.

(3) Is their a specific Gravity Forms file (i.e., file name) that contains and injects this code? Once known, it will be easier to defer or delay the file.

(4) Will delaying or deferring this code (or associated files) impact the performance and display of our Gravity Forms?

Thank you!

Jonathan

I went to Settings > disable/turned off Output Default CSS
that seems to fix it

Hi Wenni,

Thank you for the tip!

We did that earlier (prior to posting this topic), but the styling of our gravity forms broke. According to the setting description, the setting should be disabled if you plan to use custom css in a child theme.

Questions:

(1) Are you using a child theme? We aren’t.

(2) Are you using custom CSS for your forms? We are.

Thank you!

Jonathan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.