Skip to content
FunnelGuard

Fix guide by FunnelsGuard

JavaScript error only in Safari: how to find and fix it

PRF-127High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

Every browser supports a slightly different set of built-in features, called APIs. If a script calls one that Safari lacks, Safari throws an error and stops running that script. Chrome and Firefox may run the same code without trouble.

Typical Safari messages look like TypeError: undefined is not a function, ReferenceError: Can't find variable: ResizeObserver or TypeError: x.replaceAll is not a function. The wording differs from Chrome, which is why searching for a Chrome error text often finds nothing.

Common culprits are newer or less common APIs: requestIdleCallback, structuredClone or Array.prototype.at on older iOS versions, lookbehind in regular expressions, Intl features, some date parsing formats, and new Date('2024-01-05 10:00') style strings that Safari rejects. Safari on iPhone uses the same engine in every iOS browser, so Chrome on iOS fails too.

Why it costs you leads or sales

When a script stops at an error, everything after it never runs. That can be a form validator, a submit handler, a payment button, a cookie banner or a tracking tag. Visitors see a button that does nothing, or the form submits but no conversion is recorded.

Because you and your team probably test in Chrome on a desktop, the problem stays hidden. Safari visitors, who are often a large share of mobile traffic, quietly drop off while your reports show a vague dip in conversion rate.

Where a Safari-only error breaks the funnel
  1. Ad clickVisitor arrives on an iPhone
  2. Landing page loadsPage renders normally
  3. Script calls unsupported APISafari throws an error
  4. Form submitHandler never attached
  5. Conversion tagNever fires

The error happens early, so every later step on Safari never runs.

Conversion rate by browserExample numbers
Conversion rate by browser (example)Chrome: 4.2 %; Firefox: 4 %; Safari: 1.1 %0234.241.1ChromeFirefoxSafari%

Example: the same landing page converts well in Chrome but poorly in Safari after a script error. Numbers are illustrative.

How to check if your site has it

Find the error in Safari
  1. Enable the Develop menu

    On a Mac, open Safari > Settings > Advanced and tick 'Show features for web developers' (older versions: 'Show Develop menu in menu bar').

  2. Open the console

    Load the affected page, then choose Develop > Show JavaScript Console (or press Option+Command+C). Reload and click through the form or checkout.

  3. Read the error and file

    Note the message, the file name and the line number. Check whether the file is your own code, a theme, or a third-party script.

  4. Test on an iPhone

    Connect an iPhone with a cable, enable Settings > Safari > Advanced > Web Inspector on the phone, then choose the device in the Mac's Develop menu to see its console.

  5. Compare with Chrome

    Run the same journey in Chrome. If Chrome shows no error and Safari does, you have a Safari-only failure.

How to fix it

The right fix depends on whether the failing call is in your own code, a plugin or theme, or a third-party script. Start by checking the API on a compatibility reference such as MDN's browser support table or caniuse.com.

Fix the unsupported API
  1. Identify the exact call

    From the console line number, find the function or property Safari does not recognise.

  2. Add a feature check

    Test whether the API exists before using it, and fall back to something simpler if not.

  3. Or add a polyfill

    A polyfill is a small script that supplies the missing feature. Load it before the code that needs it.

  4. Transpile modern syntax

    If the error is a syntax or method issue, set your build tool's browser targets (for example a browserslist including Safari 14 or the iOS versions you support) so it converts newer code.

  5. Update or replace the third-party script

    If the error is inside a vendor file, update the plugin or tag to the latest version, or contact the vendor with the Safari version and error text.

Feature check with a fallbackjavascript
// Example: requestIdleCallback is missing in Safari
const runLater = window.requestIdleCallback
  ? (fn) => window.requestIdleCallback(fn)
  : (fn) => setTimeout(fn, 1);

runLater(() => {
  initTracking();
});

// Example: replaceAll on older Safari
const clean = (s) => s.split('-').join(' ');
Guard code so one failure does not stop the restjavascript
try {
  initFancyWidget();
} catch (e) {
  console.error('Widget failed', e);
}
// The form handler below still runs
initFormHandler();
Where to apply the fix
  1. Find the source file

    The console file path shows /wp-content/plugins/... or /wp-content/themes/.... That tells you which plugin or theme is responsible.

  2. Update or swap

    Update the plugin or theme. If the error remains, deactivate it on a staging copy to confirm, then replace it or ask the author for a fix.

  3. Add a fallback for custom code

    For your own snippets, use a child theme or a code snippets plugin and add the feature check shown above.

How to confirm it's fixed

Confirmation checklist
  • Safari console shows no red errors on the landing page, form and thank-you page
  • The form submits and the test lead reaches your inbox or CRM
  • Conversion tags fire after submit (check in each ad platform's test view or in Tag Manager Preview)
  • The same journey works on an iPhone, not only on desktop Safari
  • Chrome and Firefox still work as before
Safari before and after the fix

Before

  • Console shows TypeError in Safari
  • Submit button does nothing
  • Conversion tag never fires

After

  • Feature check or polyfill in place
  • Form submits and shows confirmation
  • Conversion tag fires once

How to prevent it happening again

Prevention habits
  • Test every release in real Safari on desktop and iPhone, not just Chrome
  • Set and document the browser versions you support
  • Check MDN or caniuse.com before using a new API
  • Keep plugins, themes and tag templates updated
  • Review new third-party scripts in Safari before adding them
  • Monitor key journeys on a schedule so a bad deploy is caught quickly

How FunnelGuard handles this

FunnelGuard detects this issue. A robot visitor runs your real journeys, such as a lead form or checkout, on a schedule, including in Safari. During those runs it records console errors, so a no_console_errors check fails when Safari logs an error, and it flags steps that fail in one browser but not another.

A failure is re-checked from a second region before one alert goes out, with a screenshot and a likely cause. FunnelGuard tells you that Safari hit an error and on which step. You still need to read the message and apply the code fix yourself.

The Free plan covers 1 site and 2 journeys with daily checks and no card. Paid plans start at $39/month and include a 3-day free trial. A free read-only website audit is also available.

Questions people ask

Why does my website work in Chrome but not in Safari?

Safari uses the WebKit engine and supports a different set of browser features than Chrome. If your code or a plugin calls an API Safari lacks, it throws an error and stops that script. Open Safari's Web Inspector console to see the exact message.

How do I see JavaScript errors in Safari?

Enable the Develop menu in Safari > Settings > Advanced, then choose Develop > Show JavaScript Console and reload the page. For an iPhone, turn on Settings > Safari > Advanced > Web Inspector and connect it to a Mac.

Why is my form not submitting on iPhone?

A JavaScript error that stops the submit handler from loading is a common cause, especially if the form works in Chrome on desktop. Other causes include a covered button or a required field that cannot be completed. Check the console in Safari first.

Does Chrome on iPhone use Safari's engine?

Yes. Apple requires browsers on iOS to use WebKit in most regions, so Chrome and Firefox on an iPhone behave much like Safari. A Safari-only bug often affects every iPhone visitor.

What does 'undefined is not a function' mean in Safari?

It means the code called something as a function that does not exist in Safari, often a newer built-in method. Look at the file and line in the console, then add a feature check or a polyfill.

What is a polyfill and do I need one?

A polyfill is a small script that adds a feature a browser is missing, so your code can use it everywhere. You need one when you rely on an API that your supported Safari versions lack and you cannot avoid it.

Can a Safari-only error stop my ad conversions being tracked?

Yes. If the error happens before the tracking tag runs, or inside it, the conversion is never sent. Your ad platform then under-reports Safari conversions.

How can I catch Safari errors automatically?

Run your key journeys on a schedule in Safari and record console errors. FunnelGuard does this and alerts you with a screenshot and likely cause when a step fails or an error appears.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: Safari runs record console errors; no_console_errors and step failures per browser.

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.