When running Google's PageSpeed Insights against a WordPress website you often get told about the following opportunity to improve the website's performance.
Eliminate render-blocking resources
Resources are blocking the first paint of your page. Consider delivering critical JS/CSS inline and deferring all non-critical JS/styles. Learn more
This part of the solution uses JavaScript that is identical to the code used by people fiddling with Gravity forms JavaScript.
It's a lot easier to implement though.
The other change is to ensure the script is enqueued in the footer.
When running Google's PageSpeed Insights against a WordPress website you often get told about the following opportunity to improve the website's performance.
Eliminate render-blocking resources
Resources are blocking the first paint of your page. Consider delivering critical JS/CSS inline and deferring all non-critical JS/styles. Learn more
WordPress There are a number of WordPress plugins that can help you inline critical assets or defer less important resources.
Beware that optimizations provided by these plugins may break features of your theme or plugins, so you will likely need to make code changes.
Requirement
Proposed solution
Wrap the inline JavaScript written by the server side rendering with:
and
This part of the solution uses JavaScript that is identical to the code used by people fiddling with Gravity forms JavaScript. It's a lot easier to implement though.
The other change is to ensure the script is enqueued in the footer.
simplify the enqueue_script call
and to remove the hook that enqueues the script willy-nilly.
In this explanation I've just commented out the code that's not necessary any more.