Install the widget
Write the config object first, then load the script. The widget reads
window.subblyConfig the moment it runs, so the order matters.
Embed the widget
Your Storefront API key is in the Subbly admin, under Settings, Developers.
The script tag carries no data- attributes; everything goes through the
config object. cart-widget.js is a small loader that imports the real bundle
and its stylesheet, so do not cache it. The files it pulls from assets/
carry a hash in the name and can be cached for a long time.
Wait for the widget
The script loads asynchronously. The widget fires two events on window.
Neither carries data.
| Event | Meaning |
|---|---|
subbly-cart-loaded | The code is downloaded and window.SubblyCart, the class, is set. There is no instance yet. |
subbly-cart-initialized | The widget is up and window.subblyCart, the instance, is set. Wait for this one. |
There is no ready callback and no command queue. Guard against the event having already fired:
Run code once the widget is ready
The other pages in this section use this onReady helper.
The widget also emits its own
CART_READY event, but it fires
inside initialize(), before the instance is handed out, so no handler of
yours can see it. Read the cart from subblyCart.cart once
subbly-cart-initialized has fired instead.
Next steps
- Configure — the keys of
window.subblyConfig. - Wire it into your page — buy links, your own cart button and the container.