JavaScript (global.js)
Citera ships one deferred, dependency-free JavaScript file. It leans on the
native <dialog> element and Shopify’s Section Rendering API so there’s no
framework and no full-page reloads for cart actions.
Drawers (native <dialog>)
openDialog()/closeDialog()helpers- Click handlers bound to
[data-drawer-open]and[data-drawer-close] - Scroll is locked while open and restored on close; clicking the backdrop closes
AJAX cart
Wraps Shopify’s cart endpoints:
postCart()— calls/cart/add.js,/cart/update.js,/cart/change.jsrefreshCartDrawer()— re-renders just#cart-drawer-content(drawer stays open, items update in place) via the Section Rendering APIupdateCartCount()— reads/cart.jsand updates[data-cart-count]badges- A form interceptor on
[data-cart-form]submits viapostCart()and opens the drawer instead of navigating
Cart drawer persistence
updateCartField()— POSTs cart note and gift attributes to/cart/update.jswithout re-rendering the drawer
Cart upsell
loadCartUpsell()— fetches/recommendations/products?...§ion_id=cart-upselland injects results into[data-cart-upsell](see the cart-upsell section)
Quick view
- Fetches
/products/{handle}?section_id=quick-viewvia the Section Rendering API and injects the markup into the#quick-viewmodal, so shoppers preview a product without leaving the page.
Countdown
- Drives
[data-countdown]elements from adata-countdown-endISO timestamp, anchored to the store timezone, switching to an “ended” state at the deadline.
Because everything goes through the Section Rendering API, the server-rendered Liquid stays the single source of truth — the JS only swaps HTML fragments Shopify returns, so cart markup never drifts between server and client.