JavaScript globals
Everything the theme puts on window, where it comes from, and what reads it.
src/@types/global.ts declares these types. People write and update those declarations by hand, and nothing checks them
against Liquid, so treat them as documentation, not a guarantee. See
Liquid to JavaScript contract.
window.theme
| Key | Written by | Consumed by |
|---|---|---|
pageType | layout/theme.liquid | Page-specific branching |
moneyFormat, moneyWithCurrencyFormat, shopCurrency | layout/theme.liquid | formatMoney and shopifyFormatCurrency in src/entrypoints/utils.ts |
productImageSize, searchMode | layout/theme.liquid | Prestige code |
showPageTransition, showElementStaggering, showImageZooming | layout/theme.liquid | Prestige animation code |
labels | layout/theme.liquid | Translated strings across components |
labels.medispa | layout/theme.liquid | Remaining balance wording in the cart |
gift_product | layout/theme.liquid | src/components/purchase-gift-manager/ |
cartRewardBanner | layout/theme.liquid | src/components/cart-reward-banner/ |
medispaCalendarConfig | snippets/medispa-calendar-config.liquid | src/components/medispa-calendar/ |
popupManagerConfig | snippets/popup-logic.liquid | No script reads it. It exists only when the popup manager is enabled |
needHelpPopup | sections/need-help-popup.liquid | The need-help popup definition |
packOptions | snippets/pack-options-config.liquid | src/entrypoints/pack-options.ts |
plpSegmentationTiles | sections/plp-segmentation-tiles.liquid | Collection page tiles |
selectOptionsModalConfig | sections/select-options-modal.liquid | src/entrypoints/select-options-modal.ts |
After the base object, the snippets that add keys run in no fixed order. Each one creates its key only if it is missing,
with window.theme.x = window.theme.x || {}. Several keys are optional in the type because only some templates render
the snippet that adds them.
Two implementations of deferJS
Each of the three layouts defines window.deferJS inline, for Liquid and older scripts. src/components/utils/defer.ts
exports its own defer and deferJS, and bundled TypeScript imports those instead of reading the global. The two are
separate implementations, and changing one does not change the other.
Globals the theme defines
| Global | Defined in | Purpose |
|---|---|---|
enableLogging(value?) | src/lib/logger.ts | Turn console output on. '*' or a comma-separated namespace list |
disableLogging() | src/lib/logger.ts | Turn console output off |
deferJS(fn, condition) | layout/theme.liquid and its two siblings, inline | Run a function once a condition holds. Defined in all three layouts |
addCheckoutEventChain(fn) | src/entrypoints/mini-cart/internals/checkout-chain.ts | Register a checkout step. Returns false with no footer element |
PopupMonitor | src/components/popup-logic/index.ts | The class, exposed for debugging |
popupMonitor | src/entrypoints/popup-logic.ts | The live instance |
popupTimer | src/entrypoints/popup-logic.ts | The 15-second popup timer |
klaviyoSniffer, customSniffer | src/entrypoints/popup-logic.ts | DOM watchers for popups |
PurchaseGiftManager | src/components/purchase-gift-manager/ | Automatic gift handling |
selectOptionsHandler | src/entrypoints/select-options-modal.ts | Opens the quick add modal |
miniCartGiftsConfig | Liquid | Gift definitions for the drawer |
Medispa.carousels | Medispa sections | Carousel instances |
Globals owned by others
The theme reads these but does not create them. Any of them can be absent.
| Global | Owner | Notes |
|---|---|---|
Shopify | Shopify | Every cart and section URL uses Shopify.routes.root |
SesamiSDK | Sesami | The booking calendar waits for it and never times out |
Swiper | Swiper library | Carousels |
jQuery | Older app scripts | Still loaded, and some older snippets still use it |
Sentry | Declared only | Typed in global.ts, but nothing in the theme initialises it. Assume no error reporting |
tbyb, TryWithMirra | Try before you buy integrations | |
offerPopupConfig | Liquid | Read by src/entrypoints/klaviyo-popup-trigger.ts |
_klOnsite | Klaviyo | The popup adapters and the collection page script push openForm commands to it |
The logger
The logger is off by default, and nothing reaches the console until a developer turns it on.
window.enableLogging('*'); // everything
window.enableLogging('cart,popup-logic'); // named namespaces
window.disableLogging();It also reads a query parameter and saves the value to localStorage under BA_DEBUG:
?ba_debug=*
?ba_debug=cart,popup-logicEach createLogger('name') call defines a namespace. Search src/ for createLogger to list them. The logger also
patches the global console, so the same switch hides direct console.log calls in older code.
The comment block at the top of src/lib/logger.ts names the helpers baDebugEnable and baDebugDisable. Those
functions do not exist. The code at the bottom of the file assigns enableLogging and disableLogging, and those are
the ones to use.