Skip to content

Widget Setup

Installation

Add the widget to your product page template:

<div id="swiftreviews"></div>
<script>
window.__swiftreviews = {
shopDomain: "{{ shop.permanent_domain }}",
productId: "{{ product.id }}",
};
</script>
<script src="https://cdn.swiftreviews.app/widget.js" async defer></script>

Configuration Options

The window.__swiftreviews object accepts:

PropertyTypeRequiredDescription
shopDomainstringYesYour .myshopify.com domain
productIdstringYesShopify product ID
apiUrlstringNoCustom API URL (for self-hosted)

How It Works

  1. The widget script loads asynchronously (never blocks page rendering)
  2. Reads configuration from window.__swiftreviews
  3. Fetches the review summary from the edge cache (~10ms)
  4. Renders the rating summary, distribution, and first page of reviews
  5. Lazy-loads the photo lightbox, submission form, and pagination as needed

Performance

  • Bundle size: <5KB gzipped
  • First render: <100ms after script loads
  • API latency: <10ms from edge cache
  • Zero layout shift: Fixed-height containers prevent CLS