Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Caching plugin breaking JavaScript (WP Rocket, LiteSpeed): fix

OPS-239High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

A caching plugin speeds up your site by storing ready-made pages and by changing how files load. Two JavaScript features cause most problems: minify/combine, which squashes many script files into one, and delay/defer, which postpones scripts until the visitor interacts or the page has loaded.

Scripts often depend on each other and on loading in a set order. When the plugin changes that order or merges files, one script can fail with an error such as jQuery is not defined, and everything after it stops working. The page still looks fine, so the break is easy to miss.

The settings usually involved are WP Rocket's Minify JavaScript files, Combine JavaScript files, Load JavaScript deferred and Delay JavaScript execution, and LiteSpeed Cache's JS Minify, JS Combine, Load JS Deferred and Delay Load JS.

Why it costs you leads or sales

The pages most affected are the ones that rely on JavaScript to convert: contact forms, multi-step forms, add-to-cart and checkout buttons, booking widgets, popups and chat. If the script fails, the button does nothing or the form never submits. Visitors do not report it. They leave.

Tracking can break too. Delaying scripts can stop the GA4, Google Ads or Meta tags from firing, or make them fire late so quick visitors are never counted. Your ad platforms then optimise on missing conversions.

Where a JS conflict breaks the funnel
  1. Ad clickVisitor lands on the page
  2. Page loadsLooks normal
  3. Script combined or delayedDependency order breaks
  4. Form submitsButton does nothing
  5. Conversion tagNever fires

The page loads, but the optimised script fails, so the form and the conversion tag never run.

Form submissions before and after enabling Combine JSExample numbers
Form submissions before and after enabling Combine JS (example)Before change: 40 submissions per week; After change: 9 submissions per week01531409Before changeAfter changesubmissions per week

Example: illustrative numbers showing a drop after a caching setting change.

How to check if your site has it

Check for a JavaScript conflict
  1. Open the page in a private window

    Log out of WordPress or use an incognito window. Logged-in admins often bypass the cache and optimisations, so the problem only shows for visitors.

  2. Open the browser console

    Press F12 (or right-click, Inspect), then open the Console tab and reload. Look for red errors such as Uncaught ReferenceError: jQuery is not defined or Unexpected token.

  3. Test the key action

    Submit the form, click the add-to-cart or booking button, open the chat widget. Note which ones fail.

  4. Compare with optimisation off

    Add ?nowprocket to the URL for WP Rocket, or ?LSCWP_CTRL=NOCACHE for LiteSpeed (this needs the plugin's debug or admin settings in some setups). If the page works with it, the plugin is the cause.

  5. Check your tracking

    Use the Network tab and filter for collect, googleads or facebook to see whether the tracking requests are sent.

How to fix it

The safe method is to switch off the riskiest options first, confirm the site works, then turn features back on one by one. Take a backup or work on a staging copy if you can.

Fix by caching plugin
  1. WP Rocket: turn off the risky options

    Go to Settings, WP Rocket, File Optimization. Untick Combine JavaScript files, Load JavaScript deferred and Delay JavaScript execution. Save and clear the cache. Test the form and tracking.

  2. WP Rocket: turn options back on one at a time

    Re-enable one option, clear the cache, test again. When it breaks, you have found the cause.

  3. WP Rocket: add exclusions

    Under Delay JavaScript execution or Excluded JavaScript Files, add part of the script path or keyword of the failing script (for example the form plugin's file name, jquery.js, or your tracking script). Exclude only what is needed so you keep the speed gain.

  4. LiteSpeed Cache: turn off the risky options

    Go to LiteSpeed Cache, Page Optimization, JS Settings. Set JS Combine, Load JS Deferred and Delay Load JS to Off. Save, then use Toolbox, Purge All.

  5. LiteSpeed Cache: exclude the script

    Use the JS Excludes, JS Deferred / Inline JS Excludes and Delay Load JS Excludes fields to list the failing script. Re-enable options one at a time and test after each.

Keep a script out of optimisationhtml
<!-- WP Rocket -->
<script src="/path/to/form.js" data-no-minify="1"></script>

<!-- LiteSpeed Cache -->
<script src="/path/to/form.js" data-no-optimize="1"></script>

How to confirm it's fixed

Fix confirmation
  • Cache purged in the plugin and, if you use one, at your host or CDN
  • No red errors in the browser console on the affected pages
  • Form submits and shows its thank-you message or page
  • Test lead arrives in the inbox and CRM
  • Add-to-cart, checkout and booking buttons work
  • Tracking requests for GA4, Google Ads and Meta appear in the Network tab
  • Checked in a private window and on mobile

How to prevent it happening again

Treat every change to cache settings, and every plugin or theme update, as a possible break. Test the money pages afterwards, not just the homepage.

Prevention habits
  • Change one optimisation setting at a time and test after each
  • Use a staging site for cache and update changes
  • Keep a list of scripts you excluded and why
  • Purge the cache after every plugin, theme or setting change
  • Test forms, checkout and tracking from a logged-out browser after updates
  • Run an automated check of your key journeys on a schedule

How FunnelGuard handles this

FunnelGuard detects this today. It does not read your cache settings. It runs your real journeys as a logged-out robot visitor, so it sees what a customer sees after your caching plugin has rewritten the scripts. If a form button stops working, a step fails, or the tracking hits to GA4, Google Ads, Meta or other platforms are no longer sent, the check fails.

A failure is re-checked from a second region before one alert goes out, with a screenshot and a likely cause. That helps you catch a break soon after an update or a settings change. The Free plan covers 1 site and 2 journeys with daily checks and no card.

A delayed script never fires its tag

The caching plugin holds the script back, so the tracking tag does not send its hit.

Delay JavaScript settingInteractive
Delay JavaScript execution

Delay on, no exclusions

Leads or data lost

The form script waits for interaction, submissions fail and conversion tags may not fire.

Toggle to see how excluding the key scripts changes the outcome.

Questions people ask

Why is my form not working after installing WP Rocket?

Most often WP Rocket's Delay JavaScript execution, Combine JavaScript files or Load JavaScript deferred is changing how the form's script loads. Turn those options off, clear the cache and retest. Then re-enable them one at a time and exclude the script that breaks.

How do I exclude a JavaScript file from WP Rocket?

Go to Settings, WP Rocket, File Optimization and add part of the script's path to Excluded JavaScript Files or the Delay JavaScript execution exclusion list. You can also add data-no-minify="1" to scripts you load yourself. Save and clear the cache.

Why is my LiteSpeed Cache breaking my site's JavaScript?

JS Combine, JS Minify, Load JS Deferred and Delay Load JS under Page Optimization, JS Settings can reorder or merge scripts and break dependencies. Switch them off, purge all, then re-enable one at a time and use the exclude fields for the script at fault.

How can I tell if a caching plugin is causing the problem?

Load the page in a private window and check the browser console for red errors. Then test with the plugin's optimisation off, for example the ?nowprocket URL parameter in WP Rocket. If the problem disappears, the cache plugin is involved.

Can a caching plugin stop my Google Ads or Meta tracking?

Yes. If it delays or defers the tag script, the tag may fire late or not at all, so conversions go unrecorded. Exclude your tag manager or tracking script from delay and defer, then confirm the requests appear in the Network tab.

Do I need to clear the cache after changing JavaScript settings?

Yes. Cached files can keep serving the old broken version. Purge the cache in your plugin, and at your host or CDN if they have their own cache, then retest in a private window.

Should I stop using a caching plugin altogether?

Usually not. The speed benefits are real. Keep the safe settings, switch off the JavaScript options that cause trouble, and exclude only the scripts that need to load normally.

How can I be alerted if a cache setting breaks my forms?

FunnelGuard runs your form and checkout journeys on a schedule as a logged-out visitor, checks the tracking hits and test leads, and alerts you with a screenshot if a step fails.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

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.