Skip to content

Turn off Rocket Loader for Gravity Forms scripts

If you’re using CloudFlare to speed up your site and you’re having issues with Gravity Forms features relaying on javascript such as conditional logic, calculations or multi-file upload you have a lot of chances of having Rocket Loader feature enabled in your CloudFlare account.

According to CloudFlare, Rocket Loader can improve load times for pages that include JavaScript. But Rocket Loader is considered Beta because it’s an experimental feature that modifies the loading and execution flow of Javascript. In fact it’s in beta since years.

Using a beta feature is not a good choice for a production site, so what I would recommend you is to turn off Rocket Loader in the Speed section of your CloudFlare account. But if you like taking risks and you think all other scripts in your site are working fine with Rocket Loader enabled CloudFlare also allows you to exclude only certain scripts of your site where Rocket Loader will be not applied.

To achieve this you need to add the attribute data-cfasync=’false’ before the ‘src’ attribute to the HTML script tag used to embed the script in your page. Using WP core filter script_loader_tag we can do that.

The below snippet will add the mentioned attribute to all script files used by Gravity Forms when these are enqueued.

After adding the snippet to your site, make sure to Purge Everything in the Caching section of your CloudFlare account and empty your browser cache.

Published inGravity Forms

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *