Skip to content
FunnelGuard

Fix guide by FunnelsGuard

JavaScript unsupported syntax in older browsers: find and fix

CNV-389Medium impactCould addBy FunnelGuardPublished Updated
On this page

What this issue is

JavaScript keeps getting new syntax. Examples are optional chaining (a?.b), nullish coalescing (a ?? b), and class fields. Newer browsers understand them. Older browsers, such as old iPhones that no longer get updates, do not.

This is different from a missing feature. A missing feature (like fetch in a very old browser) only fails when the code runs. Unsupported syntax fails at parse time: the browser cannot read the file, so it throws a SyntaxError and runs none of it. One new operator can take down an entire bundle.

Why it costs you leads or sales

When the script fails, the page may still look fine, because HTML and CSS load. But the form validation, submit handler, add-to-cart button, chat widget or tracking tags that rely on that script do nothing. The visitor taps and nothing happens, and you see no error.

The share of affected visitors is usually small, but it is often invisible in your reports. Those visitors also never fire your analytics, so you cannot see them dropping off.

How one unsupported operator breaks the funnel
  1. Page loadsHTML and CSS display normally
  2. Script parsedSyntaxError: unexpected token '?'
  3. Form submitsHandler never attached
  4. Tracking firesNo conversion hit sent

The script fails to parse, so everything after it is lost.

Form submissions by browser ageExample numbers
Form submissions by browser age (example)Current browsers: 4 %; Older browsers: 0 %02340Current browsersOlder browsers%

Example: illustrative conversion rates only. Visitors on an older browser can convert at close to zero when the script fails.

How to check if your site has it

Check for syntax your audience's browsers cannot read
  1. Look at your analytics for older browsers

    In GA4, open Reports > Tech > Tech details and choose Browser or Operating system version. Note which older versions still visit and how their conversion rate compares.

  2. Open the site in an older browser

    Use an older real device if you have one, or a cloud testing service such as BrowserStack or LambdaTest. Try the form, the buttons and the checkout.

  3. Read the console

    Open developer tools and look for errors like 'SyntaxError: Unexpected token' or 'Unexpected token ?'. Note the file named in the error.

  4. Scan your built filesCustom code

    Run a syntax check against your target browsers (see the code below). It lists lines your target cannot parse.

  5. Check third-party scripts

    If the failing file is from a plugin, app or widget, note its name. You cannot edit it, but you can update it, replace it or report it.

Check a built file against your browser targets (es-check)bash
npm install --save-dev es-check
npx es-check es2015 './dist/**/*.js'

How to fix it

The fix is to decide which browsers you support, then let a build tool rewrite modern syntax into older syntax for them. Do not rely on each developer remembering what is safe.

Fix unsupported syntax
  1. Decide your browser support

    Use your analytics to pick a realistic target. Write it in a browserslist entry so every tool shares it.

  2. Transpile with Babel or your bundler

    Use @babel/preset-env, or the equivalent option in your bundler, so it reads your browserslist and rewrites syntax.

  3. Include dependencies

    Many tools skip node_modules. If a library ships modern syntax, configure your build to transpile that package too.

  4. Add polyfills for missing features

    If older browsers also lack features such as Promise or fetch, add polyfills, for example with core-js through preset-env's useBuiltIns option.

  5. Rebuild, deploy and retest

    Run the syntax check again, then test in an older browser.

package.json: shared browser targetjson
{
  "browserslist": [
    ">0.5%",
    "last 2 versions",
    "not dead",
    "iOS >= 12"
  ]
}
babel.config.jsjavascript
module.exports = {
  presets: [
    ['@babel/preset-env', {
      useBuiltIns: 'usage',
      corejs: 3
    }]
  ]
};
What to do on your platform
  1. Find the failing file

    The console error names a file path. If it sits in /wp-content/plugins/ or /themes/, that plugin or theme is the source.

  2. Update or replace it

    Update the plugin or theme. If it is still failing, contact the developer or switch to an alternative.

  3. Check your own build

    If you use a custom theme with a build step, set browserslist and Babel as shown above.

How to confirm it's fixed

Confirmation checks
  • The es-check command passes on your built files.
  • The console shows no SyntaxError in an older browser.
  • The form submits and shows its success message.
  • The add-to-cart or booking button responds.
  • Your analytics shows a conversion event from the test visit.
  • The test lead reaches your inbox or CRM.
Before and after transpiling

Before

  • Script ships `?.` and `??` untouched
  • Older browser throws SyntaxError
  • Form and tracking do nothing

After

  • Build output matches your browserslist
  • Older browser parses the script
  • Form and tracking work

How to prevent it happening again

Prevention habits
  • Keep one browserslist in the repository and review it every few months.
  • Run es-check in your build pipeline.
  • Re-test on an older browser after plugin, theme or app updates.
  • Review GA4 browser reports for new low-converting versions.
  • Ask vendors which browsers their scripts support.

How FunnelGuard handles this

FunnelGuard does not check this yet. It is a possible future check. Its robot visitor does not run older browsers, so it will not tell you that a script fails to parse in one.

What it does cover is the real journey in a current browser: it runs your lead forms, checkouts and booking and chat buttons on a schedule, checks each step and the tracking hits sent to platforms like GA4, Google Ads and Meta, and confirms test leads reach the inbox and CRM. If a script error breaks that journey for everyone, you get an alert with a screenshot and a likely cause.

Questions people ask

Why does my form work in Chrome but not on an older iPhone?

The page likely uses JavaScript syntax the older Safari cannot parse, such as optional chaining. The browser throws a SyntaxError and runs none of that script, so the form handler never attaches. Transpile your code for older targets and retest.

What does 'SyntaxError: Unexpected token' mean?

It means the browser hit code it could not read. Often that is newer syntax like ?. or ?? in a browser that predates it. The error names the file, which shows where to look.

How do I make JavaScript work in older browsers?

Set a browserslist target and transpile with Babel or your bundler's equivalent. Add polyfills for missing features such as Promise or fetch. Then test in an older browser or a cloud testing service.

What is the difference between transpiling and polyfilling?

Transpiling rewrites new syntax into older syntax the browser can parse. Polyfilling adds missing features, such as fetch, as extra code. Older browsers often need both.

How can I tell which older browsers my visitors use?

In GA4, open Reports > Tech > Tech details and view Browser or Operating system version. Compare conversion rates for older versions against current ones to see if something is failing.

Does a third-party plugin cause this too?

Yes. A plugin, theme or app can ship modern syntax that older browsers cannot parse. The console error names the failing file, so you can see which one it is, then update, replace or report it.

Can FunnelGuard detect unsupported JavaScript syntax in older browsers?

No, not yet. It is a possible future check. FunnelGuard runs your journeys in a current browser, so it will alert you if a script error breaks a form or tracking there, but not an older-browser-only failure.

Does FunnelGuard catch this?

Could add

Not checked yet: could be added to FunnelGuard.

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.