Widget Customization

Embedding External Assets in the Widget

Load external images or stylesheets in custom widget CSS and understand cross-origin isolation (COEP) support in tinyDialog widgets.

By default, tinyDialog widgets support cross-origin isolated host pages (Cross-Origin-Embedder-Policy: require-corp) out of the box. You can embed tinyDialog on pages that use SharedArrayBuffer, WebAssembly threads, FFmpeg, or WebContainers without extra configuration.

To make this work, widget responses at /widget/v1/* send both of these headers by default:

  • Cross-Origin-Resource-Policy: cross-origin
  • Cross-Origin-Embedder-Policy: require-corp

Why external assets in custom CSS can be blocked

When your survey's custom CSS (additionalCss) references external resources—such as images in url(...) or external stylesheets via @import—the browser enforces COEP: require-corp. If the asset's origin does not send Cross-Origin-Resource-Policy: cross-origin, the browser blocks that asset.

Use one of these approaches so your widget stays compatible with cross-origin isolated pages:

  • Send the CORP header from the asset origin: Configure the server hosting your image or stylesheet to return Cross-Origin-Resource-Policy: cross-origin.
  • Inline the asset with a data: URI: For small logos, icons, or background images, inline them directly in your custom CSS as a data: URI.

Opt out of cross-origin isolation

If your host page is not cross-origin isolated and you cannot change the external asset or its response headers, you can disable COEP: require-corp for the widget iframe.

HTML script tag or data attributes

Add data-tinydialog-cross-origin-isolation="false" to the tinyDialog <script> tag, or to an individual data-tinydialog-openwidget or data-tinydialog-widgetcontainer element:

<script
    src="https://cdn.jsdelivr.net/npm/@tinydialog/sdk-js@latest/dist/browser.js"
    data-tinydialog-floating-button="0181b447-1234-23d1-9675-z1a295cad5d7"
    data-tinydialog-cross-origin-isolation="false"
>
</script>

JavaScript SDK (@tinydialog/sdk-js)

Pass crossOriginIsolation: false to showWidget or loadSurvey to append coi=0 to the widget iframe URL:

import {loadSurvey, showWidget} from '@tinydialog/sdk-js';

showWidget('01959b56-1bce-7d41-a68c-f19aeffc62cc', {
  crossOriginIsolation: false,
});

loadSurvey(
  '01959b56-1bce-7d41-a68c-f19aeffc62cc',
  {crossOriginIsolation: false},
  widgetContainer,
);

Manual <iframe> embed

Append ?coi=0 (or &coi=0 if other query parameters are present) to the widget URL:

<iframe src="https://app.tinydialog.com/widget/v1/0181b447-1234-23d1-9675-z1a295cad5d7?coi=0"></iframe>

Last updated on

On this page