How to embed a widget without disrupting the host page | ShopTools AI
ShopTools Guide

How to embed a widget without disrupting the host page

Design for coexistence with a merchant page: style boundaries, a single instance, accessible geometry and complete teardown.

The ShopTools AI extension helps test promo codes on supported merchant pages. An interface embedded there needs to keep checkout accessible. That is a more useful design priority than making the widget impossible to miss.

ShopTools AI search with fields for a store or purchase and shopping country
The ShopTools AI search interface on 14 September 2026. It finds offers; this screenshot does not demonstrate a discount in a shopping cart.

Choose a style boundary

JavaScript isolation does not isolate injected markup from the page's CSS. Global merchant rules can change buttons, fonts and dimensions. The options below are design choices, not a description of the current ShopTools build.

With ordinary DOM markup, scope style resets to the widget's own root. Do not restyle every merchant button to fix your panel. Check box sizing, margins, text transformations and visible keyboard focus.

Make initialization and teardown symmetrical

Running initialization again should not create another panel or another set of listeners. A root marker helps, but its presence does not establish that old subscriptions and observers were cleaned up.

Define what happens after a route change, checkout-container replacement or user disable action. Teardown should remove the widget's nodes, listeners and observers without touching the merchant's own interface.

Test re-enabling too: the interface should return exactly once. A delayed callback must not resurrect a panel the user has removed.

Do not win every stacking contest

An extremely high z-index is not a priority policy. The widget must not cover payment, error messages, delivery choices or merchant dialogs. Moving or hiding it can be more appropriate than bringing it to the front.

On a narrow screen, constrain the panel to the available space and allow its content to scroll. Long translations, larger text and the on-screen keyboard must not make primary actions unreachable.

Respect the system's reduced-motion preference. When an operation stops, its animation should stop too. Persistent pulsing is not evidence that work is taking place.

Test interference, not just appearance

  1. Create a fixture with a global button { all: unset; } rule. The widget button should retain its intended dimensions, styling and visible keyboard focus when reached with Tab.
  2. Place a dialog over checkout and verify keyboard access to merchant actions.
  3. Replace the checkout root several times, then count panels and listener invocations.
  4. Repeat at narrow widths, with larger text and reduced motion.
  5. Disable the widget while a response is pending and confirm it does not reappear.

These checks define coexistence requirements; they do not establish compatibility with every site. Even an isolated panel shares screen space and attention with the merchant. No single CSS technique removes that constraint.

By the ShopTools AI editorial team.

Some ShopTools links are affiliate links. ShopTools may earn a commission on a qualifying purchase confirmed by the retailer; a click alone does not guarantee a commission.

Prepared with AI assistance. Product descriptions were checked against ShopTools code and interface; this is not a report of tests at every store.