Skip to main content

CSP, performance and isolation

What the widget costs your page​

  • One script, about 27 KB compressed (85 KB raw), loaded async after your page. It never blocks rendering and causes no layout shift: the bubble is positioned fixed.
  • No dependencies. No framework, no fonts (it uses the visitor's system font), no images except your own logo if you set one.
  • No third parties. The only server it talks to is Sarthi (api.mysarthi.tech). No analytics, no trackers, no cookies.
  • Cached by the browser for 5 minutes, so updates reach your site quickly and repeat visits are instant.

Isolation​

The widget renders inside a Shadow DOM attached to a single <div data-saarthi-widget> at the end of <body>. Your CSS can't restyle it (a page with uppercase serif buttons still gets a normal chat), and its CSS can't reach your page. It doesn't touch window beyond window.Sarthi.

Content Security Policy​

If your site sends a Content-Security-Policy, allow these:

script-src https://api.mysarthi.tech;
connect-src https://api.mysarthi.tech wss://api.mysarthi.tech;
style-src 'unsafe-inline';
img-src https://your-logo-host.example;
DirectiveWhy
script-srcThe widget script is loaded from https://api.mysarthi.tech/widget/v1.js.
connect-srcChat messages go to api.mysarthi.tech over HTTPS; replies stream back over the same connection. Voice uses a WebSocket (wss://) to the same host.
style-src 'unsafe-inline'The widget injects its stylesheet as a <style> element inside its Shadow DOM, which CSP treats as inline. A nonce can't be applied to it from your page. If you can't allow inline styles, the chat can't be styled, so this one is required.
img-srcOnly if you set a logo in Settings → Workspace: the host it is served from.

Nothing else: no frame-src (the widget isn't an iframe), no font-src, no worker-src.

Performance tips​

  • Put the snippet last in <body>, with async, as the console gives it. Don't defer it behind a tag manager's consent gate unless you mean to hide the chat until consent.
  • Don't preload or inline the script: the 5-minute cache is tuned so updates arrive without a redeploy.
  • The chat starts when the bubble is opened, so the page's load has no extra API calls for visitors who never chat.
  • On a single-page app, load it once at the root; see React and Next.js.

The Staff assistant's script​

The Staff assistant, for your employees inside your CRM, is a separate script: https://api.mysarthi.tech/widget/staff-v1.js. It goes only on your CRM's pages; your website never loads it, and the website chat's script doesn't include any of it.

  • At most 30 KB compressed, cached for 5 minutes, loaded async, with no dependencies.
  • It calls Sarthi only once the panel is opened (or an inline assistant appears), and it only works on the CRM addresses you list.
  • It exposes only window.SarthiStaff, never touches window.Sarthi, and draws inside a closed Shadow DOM, so both can share a page.
  • On the CRM's Content Security Policy it needs the same script-src, connect-src and style-src 'unsafe-inline' as the chat, without the wss:// (it has no voice). See Install in your CRM.

Accessibility​

The launcher and panel are keyboard-reachable (Tab, Enter, Escape closes), labelled for screen readers, and the panel is a dialog. Colour contrast of your brand colour is handled automatically: text on it switches to white or near-black depending on the colour you chose.