Skip to content

Web SDK errors

TryYourSize.js throws (or emits with the loaderror event) a TryYourSizeError with a stable type and code, a message, and a docUrl that points at the matching section below.

Type Meaning
integration_error Your code called the SDK wrongly. Thrown synchronously; fix the call.
load_error Our window or script could not be loaded or reached: network, Content Security Policy, an origin not registered for the key. Emitted with loaderror, or a rejected promise.
try {
const tys = TryYourSize(window.TYS_KEY);
} catch (e) {
console.error(e.code, e.docUrl);
}

You passed a secret key (sk_…) to TryYourSize(). Secret keys must never reach a browser: anyone could read them. Use your publishable key (pk_test_… / pk_live_…) and roll the secret key if it was deployed.

The key is not a publishable key (pk_test_… or pk_live_… followed by at least 8 characters). Copy it again from Studio → Developers → API keys.

element.mount(target) found nothing: the selector matched no element, or it ran before the element was in the page. Mount after the container exists (for example after DOMContentLoaded, or in your framework’s mounted hook).

The element is already mounted. Call unmount() first, or create a second element (several of one type are allowed).

The element was destroyed with destroy(). Create a new one with elements.create().

elements.create(type) got a type that does not exist. Use "sizeGuide", "button" or "fit".

An option is missing or invalid: product is required; variant must be "link" or "button"; label is a string of at most 60 characters; demo needs a test key and { body: "sample-female-165" }; recommendation() needs a product. The message names the option.

Our window did not load or connect within 15 seconds. Emitted with loaderror. Check, in this order:

  1. Your Content Security Policy allows frame-src https://embed.tryyoursize.com (and script-src https://js.tryyoursize.com for the CDN build).
  2. The page’s origin is registered for the key’s mode in Studio (Settings → Stores → Allowed sites). http://localhost works in test mode without registering.
  3. The network: an ad blocker or a corporate proxy blocking tryyoursize.com.

See Troubleshooting.

loadTryYourSize() could not load https://js.tryyoursize.com/v1/tys.js (network, CSP script-src). The promise rejects; call loadTryYourSize() again to retry.

Was this page helpful?