<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Xerxes</title>
    <description>The latest articles on DEV Community by Xerxes (@xerxes_53cb736b854a4c1525).</description>
    <link>https://dev.to/xerxes_53cb736b854a4c1525</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3973439%2F04073838-4db1-46fa-a5b0-954b276cf023.jpg</url>
      <title>DEV Community: Xerxes</title>
      <link>https://dev.to/xerxes_53cb736b854a4c1525</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xerxes_53cb736b854a4c1525"/>
    <language>en</language>
    <item>
      <title>[Boost]</title>
      <dc:creator>Xerxes</dc:creator>
      <pubDate>Tue, 09 Jun 2026 10:09:09 +0000</pubDate>
      <link>https://dev.to/xerxes_53cb736b854a4c1525/-40pj</link>
      <guid>https://dev.to/xerxes_53cb736b854a4c1525/-40pj</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/xerxes_53cb736b854a4c1525/how-to-build-a-bulletproof-shopify-cart-event-listener-without-app-conflict-4kig" class="crayons-story__hidden-navigation-link"&gt;How to Build a Bulletproof Shopify Cart Event Listener (Without App Conflict)&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/xerxes_53cb736b854a4c1525" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3973439%2F04073838-4db1-46fa-a5b0-954b276cf023.jpg" alt="xerxes_53cb736b854a4c1525 profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/xerxes_53cb736b854a4c1525" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Xerxes
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Xerxes
                
              
              &lt;div id="story-author-preview-content-3855548" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/xerxes_53cb736b854a4c1525" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3973439%2F04073838-4db1-46fa-a5b0-954b276cf023.jpg" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Xerxes&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/xerxes_53cb736b854a4c1525/how-to-build-a-bulletproof-shopify-cart-event-listener-without-app-conflict-4kig" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jun 9&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/xerxes_53cb736b854a4c1525/how-to-build-a-bulletproof-shopify-cart-event-listener-without-app-conflict-4kig" id="article-link-3855548"&gt;
          How to Build a Bulletproof Shopify Cart Event Listener (Without App Conflict)
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/shopify"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;shopify&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/javascript"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;javascript&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/webdev"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;webdev&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/frontend"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;frontend&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/xerxes_53cb736b854a4c1525/how-to-build-a-bulletproof-shopify-cart-event-listener-without-app-conflict-4kig" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="18" height="18"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;1&lt;span class="hidden s:inline"&gt;&amp;nbsp;reaction&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/xerxes_53cb736b854a4c1525/how-to-build-a-bulletproof-shopify-cart-event-listener-without-app-conflict-4kig#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            2 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>How to Build a Bulletproof Shopify Cart Event Listener (Without App Conflict)</title>
      <dc:creator>Xerxes</dc:creator>
      <pubDate>Tue, 09 Jun 2026 09:51:01 +0000</pubDate>
      <link>https://dev.to/xerxes_53cb736b854a4c1525/how-to-build-a-bulletproof-shopify-cart-event-listener-without-app-conflict-4kig</link>
      <guid>https://dev.to/xerxes_53cb736b854a4c1525/how-to-build-a-bulletproof-shopify-cart-event-listener-without-app-conflict-4kig</guid>
      <description>&lt;p&gt;If you’ve ever built a slide-out cart drawer, a dynamic free-shipping bar, or custom analytics tracking for a Shopify store, you've run straight into this brick wall: &lt;strong&gt;Shopify themes do not emit consistent, trustworthy cart events.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You write a perfect event listener, only to find out a third-party product-bundle app uses old-school &lt;code&gt;XMLHttpRequest&lt;/code&gt; (XHR) instead of &lt;code&gt;fetch&lt;/code&gt; to add items to the cart. Your listener misses it completely, the cart drawer stays shut, and your user thinks the button is broken.&lt;/p&gt;

&lt;p&gt;Most developers end up copying and pasting messy, brittle &lt;code&gt;window.fetch&lt;/code&gt; overrides into their projects. &lt;/p&gt;

&lt;p&gt;Frustrated by solving this over and over again, I built &lt;strong&gt;Shopify Cart Broadcaster&lt;/strong&gt;—a zero-dependency, 2 KB utility that intercepts &lt;em&gt;both&lt;/em&gt; Fetch and XHR requests seamlessly to provide universal DOM events.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Check out the source on GitHub:&lt;/strong&gt; &lt;a href="https://github.com/Rabin-p/shopify-cart-broadcast" rel="noopener noreferrer"&gt;Rabin-p/shopify-cart-broadcast&lt;/a&gt; (If this saves you an afternoon of debugging, drop a ⭐!)&lt;/p&gt;




&lt;h3&gt;
  
  
  The Nightmare of the &lt;code&gt;/cart/add&lt;/code&gt; Response
&lt;/h3&gt;

&lt;p&gt;Even if you successfully listen to Shopify's &lt;code&gt;/cart/add.js&lt;/code&gt; request, Shopify throws another curveball at you. &lt;/p&gt;

&lt;p&gt;When you add an item to the cart, the server responds with &lt;strong&gt;only the item(s) that were just added&lt;/strong&gt;—not the updated state of the entire cart. If your slide-out cart drawer needs the new total price to see if a discount threshold is met, you are out of luck. &lt;/p&gt;

&lt;p&gt;You're forced to manually chain another &lt;code&gt;fetch('/cart.js')&lt;/code&gt; request to get the true state. &lt;/p&gt;

&lt;p&gt;My utility handles this annoying race-condition out of the box. It detects the mutation type, intercepts it, pushes the true cart events to the window and displays it beautifully.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;shopify:cart-updated&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Always gives you the accurate, updated cart object!&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;New Cart Total:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;detail&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cart&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;total_price&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>shopify</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
