Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Rocket Loader breaking tags or forms: how to find and fix it

OPS-116High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

Rocket Loader is a Cloudflare setting that rewrites your page so JavaScript loads later, after the rest of the page. Other tools do the same thing under names like "delay JavaScript", "defer JS" or "JS optimisation" (for example in WP Rocket, LiteSpeed Cache or Autoptimize).

Why it costs you leads or sales

There are two kinds of damage. First, forms and buttons break: a submit does nothing, a validation script fails, or a checkout button never reacts. Those are lost leads and sales. Second, tracking breaks silently: the conversion happens but GA4, Google Ads or Meta never hear about it. Your reports undercount and ad platforms optimise on bad data.

Where a delayed script breaks the journey
  1. Ad clickVisitor lands on the page
  2. Page loadsLooks normal
  3. Scripts rewrittenRocket Loader delays or reorders JS
  4. Form submitHandler missing or fails
  5. Conversion tagNever fires

The page loads, but the form script is delayed and the submit fails, so every later step is lost.

Reported vs real conversionsExample numbers
Reported vs real conversions (example)Real leads: 50 conversions per week; Leads reported by tags: 31 conversions per week019385031Real leadsLeads reported by tagsconversions per week

Example: a site where delayed scripts stop the conversion tag firing on some visits.

How to check if your site has it

Check for script delay problems
  1. Look at the page source

    View source and search for rocket-loader or type="text/rocketscript" (older versions) or script src values containing /cdn-cgi/scripts/. These show Rocket Loader is active.

  2. Check the Cloudflare setting

    In Cloudflare go to Speed > Optimization > Content Optimization and see if Rocket Loader is on.

  3. Test in a private window

    Open the page, open DevTools > Console, and submit the form. Look for errors such as "$ is not defined" or "Uncaught ReferenceError".

  4. Check tags fire

    In DevTools > Network, filter for collect, g/collect, tr or conversion. Submit the form and confirm the hits appear. Google Tag Assistant can also show whether tags fired.

  5. Compare with the feature off

    Turn Rocket Loader off (or add ?nocache style bypass rules if you use them) and repeat. If it works with it off, you have found the cause.

A tag that never fires

The visitor converts, but the delayed script never sends the hit.

How to fix it

You have two options. The safest is to turn the optimisation off for pages with forms, checkouts and tags. The more precise one is to leave it on and exclude only the scripts that break.

Fix by platform
  1. Exclude a script from Rocket Loader

    Add data-cfasync="false" to the script tag, for example <script data-cfasync="false" src="/js/form.js"></script>. Put it on the form, consent and tag manager scripts.

  2. Or turn it off in Cloudflare

    Go to Speed > Optimization > Content Optimization and switch Rocket Loader off. You can also use a Configuration Rule to disable it only on URLs such as /contact* or /checkout*.

  3. Purge the cache

    In Caching > Configuration choose Purge Everything so visitors get the updated HTML.

Exclude important scripts from Rocket Loaderhtml
<script data-cfasync="false" src="https://www.googletagmanager.com/gtm.js?id=GTM-XXXXXXX"></script>
<script data-cfasync="false" src="/js/form-handler.js"></script>
Before and after

Scripts delayed

  • Form script loads late
  • Submit does nothing or errors
  • Conversion tags missing from Network tab

Scripts excluded

  • Form script loads on time
  • Submit works and shows thank-you
  • Tag hits sent to ad and analytics platforms

How to confirm it's fixed

Confirmation checks
  • Page source no longer shows Rocket Loader rewriting your key scripts
  • The Console shows no script errors on page load
  • A test form submission succeeds and the thank-you page appears
  • The Network tab shows the expected GA4, Google Ads and Meta hits
  • The test lead arrives in your inbox and CRM
  • You tested on mobile as well as desktop

How to prevent it happening again

Treat speed settings as risky changes. Each time you enable Rocket Loader, Delay JavaScript or a new optimisation plugin, or install a plugin that changes script loading, run a full test of your forms and tags straight away. Keep a short list of scripts that must be excluded, and re-check it when you change themes, form tools or consent tools.

How FunnelGuard handles this

FunnelGuard detects this issue today. A robot visitor runs your real journeys on a schedule, such as filling in a lead form, and checks the tag and submit contracts: whether the form actually submits, and whether the tracking hits for GA4, Google Ads, Meta and other platforms are sent. If a script change stops a submit or a tag, the check fails.

Questions people ask

Why is my form not submitting after I enabled Rocket Loader?

Rocket Loader delays JavaScript until after the page loads. If your form handler or validation script is delayed or reordered, the submit button may do nothing. Add data-cfasync="false" to the form script or turn Rocket Loader off for that page.

Does Cloudflare Rocket Loader break Google Tag Manager?

It can. Rocket Loader may delay or reorder the GTM snippet and the scripts it loads, so tags fire late or not at all. Add data-cfasync="false" to the GTM script and test with GTM Preview mode.

How do I exclude a script from Rocket Loader?

Add the attribute data-cfasync="false" to the script tag, for example <script data-cfasync="false" src="/js/form.js"></script>. Rocket Loader then leaves that script alone. Purge your cache afterwards.

Should I turn Rocket Loader off?

If you have forms, checkouts or conversion tracking, it is safest to turn it off or exclude those pages and scripts. Rocket Loader can help speed on content pages, so a rule that only disables it on key pages is a good middle path.

Why are my Meta Pixel and Google Ads conversions missing after a speed change?

Delayed or combined JavaScript can stop tracking scripts from running before the visitor converts or leaves. Check the Network tab for the tag hits after a test submission. If they are missing, exclude the tracking scripts from the optimisation.

How do I know if Rocket Loader is active on my site?

Check Speed > Optimization > Content Optimization in Cloudflare. You can also view the page source and look for scripts served from /cdn-cgi/scripts/ or rewritten script types.

Does this affect WordPress delay JavaScript plugins too?

Yes. Options such as Delay JavaScript, Defer JS or Combine JS in plugins like WP Rocket or Autoptimize can cause the same problems. Use each plugin's exclusion list for your form, consent and tag scripts.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: Tag and submit contracts.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.