Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Minify/combine breaking scripts: how to find and fix it

OPS-117High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

Minification removes spaces, comments and long names from code so files are smaller. Combining (also called concatenating or bundling) joins many script files into one to save requests. Both are offered by cache plugins (WP Rocket, LiteSpeed Cache, W3 Total Cache, Autoptimize), by CDNs and by some hosts.

Why it costs you leads or sales

A single error can stop a form from submitting, a menu from opening, a payment button from loading or a tracking tag from firing. You keep paying for ad clicks, but visitors cannot convert, or conversions are not recorded and ad platforms optimise on bad data. The page looks normal to you, so it can stay broken for weeks.

How one bad combined file hurts the funnel
  1. Ad clickVisitor lands on page
  2. Combined JS loadsConsole error: Uncaught ReferenceError
  3. Form or checkoutButton does nothing
  4. Conversion tagNever fires

A script error in the combined file stops later code from running.

Form submissions per weekExample numbers
Form submissions per week (example)Before change: 40 submissions; After change: 6 submissions; After fix: 39 submissions0153140639Before changeAfter changeAfter fixsubmissions

Example: a form script breaks after a cache plugin update turns on combine JS.

How to check if your site has it

Check for script errors
  1. Open the page in a private window

    Use the landing page, form page or checkout that matters. Private mode avoids extensions and logged-in cache bypass.

  2. Open the console

    Press F12 (or Cmd+Option+J on Mac), then choose the Console tab. Reload the page.

  3. Look for red errors

    Typical ones: Uncaught SyntaxError, Uncaught ReferenceError: jQuery is not defined, or $ is not a function. Note the file name, often a long hashed file in a cache or min folder.

  4. Test the optimisation

    Add a query string your plugin supports to skip optimisation (for example ?nowprocket on WP Rocket), or turn the setting off temporarily. If the error disappears, minify or combine is the cause.

  5. Try the action

    Submit the form and click the checkout or booking button. Check that the tracking tag fires in the Network tab.

How to fix it

The safest fix is to change one setting at a time. Turn off combine first, since it breaks scripts most often. Then, if needed, exclude the specific file from minify. Clear all caches after each change.

Fix by platform
  1. Turn off combine

    In your cache plugin, find the file optimisation settings (WP Rocket: Settings > File Optimization; Autoptimize: Settings > Autoptimize; LiteSpeed: Page Optimization > JS Settings). Untick Combine JavaScript.

  2. Exclude the broken file

    Add the script name from the console error to the exclusion list for minify and combine. Also exclude jQuery if the error mentions it.

  3. Clear caches

    Purge the plugin cache, your host cache and any CDN cache, then retest.

Load libraries in the right orderhtml
<script src="/js/jquery.min.js" defer></script>
<script src="/js/form-handler.js" defer></script>
Console and journey

Broken

  • Red error in the console
  • Form button does nothing
  • Conversion tags missing

Fixed

  • Console is clean
  • Form submits and shows thank-you page
  • Tags fire on the thank-you step

How to confirm it's fixed

Confirmation checklist
  • Hard refresh the page and confirm the console has no red errors from your scripts
  • Submit a real test lead and see it arrive in your inbox and CRM
  • Start a checkout up to the payment step and confirm buttons work
  • Check the Network tab for GA4, Ads and Meta requests on the key action
  • Test on mobile and desktop
  • Test in a private window so cache is not hiding the problem

How to prevent it happening again

Most breakages come from a plugin update, a new setting or a new script. Treat optimisation settings like code changes.

Prevention habits
  • Change one optimisation setting at a time and test the form and checkout straight after
  • Keep a list of excluded files so you do not lose it after a plugin reset
  • Prefer minify only; skip combine on HTTP/2 or HTTP/3 sites where it gives little gain
  • Test updates on staging
  • Clear every cache layer after a change
  • Run an automated journey check after each deploy

How FunnelGuard handles this

FunnelGuard detects this today. A robot visitor runs your real journeys on a schedule, such as a lead form or checkout, and records the browser console errors it sees on the way. A script error from a minified or combined file shows up as a console error on that step, and the check also notes if the form fails or a tracking hit is missing.

A failure is re-checked from a second region before one alert goes out, with a screenshot and a likely cause. FunnelGuard points you to the error; you still need to decide which file to exclude. The Free plan covers 1 site and 2 journeys with daily checks, and paid plans start with a 3-day free trial.

A script error stops the page

One console error can stop the form and the tracking behind it.

How it unfolds
  1. Day 1

    Combine JS is switched on to improve speed scores

  2. Day 1

    A script now loads before its library and throws an error

  3. Days 2-10

    Ad spend continues, form submissions drop unnoticed

  4. Day 11

    Console error found, file excluded, caches cleared

Questions people ask

Why did my form stop working after I enabled minify or combine JavaScript?

Combining or minifying changed how scripts load, so one now runs before something it needs or has been rewritten incorrectly. The browser throws an error and stops the code, which can include your form handler. Open the console to see which file fails, then exclude it.

How do I find which JavaScript file is breaking my site?

Open the page, press F12, go to the Console tab and reload. The red error shows the file name and line. Then turn off minify or combine briefly to confirm that it is the cause.

Should I combine JavaScript files on my website?

Often not. On modern HTTP/2 or HTTP/3 hosting, combining brings little speed gain and breaks scripts more often than minifying alone. If you do combine, test forms, checkout and tracking afterwards.

Can minification stop Google Ads or GA4 tracking?

Yes. If a script error stops code that sends the conversion event, or the tag script itself is altered, the hit never reaches the platform. Check the Network tab on the key action to see if the request is sent.

How do I exclude a script from minification in WordPress?

In your cache plugin's file optimisation settings, add the script's file name or path to the exclusion field for minify and combine JavaScript. In WP Rocket this is under Settings > File Optimization. Clear the cache afterwards.

Why does my site work when I'm logged in but break for visitors?

Many optimisation plugins skip minify or cache for logged-in users. Visitors get the optimised files, so the error only appears for them. Always test in a private window.

Does a Cloudflare auto minify setting break scripts?

It can if a file does not minify cleanly. If you use a CDN optimisation feature and see console errors, disable it for JavaScript and compare. Check your CDN's current settings, as options change.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: Console errors.

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.