How to Fix JavaScript Issues in Shopify
Shopify JS problems come from three sources: app conflicts (two apps both manipulating the cart drawer), theme JS errors (incompatible theme/app combinations), and render-blocking scripts (especially analytics and tracking). This guide covers Shopify-specific JS debugging. Pair with JS Checker guide.
Step-by-step: How to fix Shopify JavaScript issues
- Open DevTools console. F12 → Console. Load homepage, collection, product, cart. Note all errors and warnings. Most Shopify stores have at least one JS error in console.
- Identify error source. Each error shows the source file (typically from cdn.shopify.com for theme JS or extensions.shopifycdn.com for app JS). Trace back which app or theme section.
- Disable apps to isolate. Shopify's dev store / staging: disable apps one-by-one, retest. Find conflict. Most JS errors come from 1-2 specific apps interacting badly with theme.
- Defer analytics and tracking JS. Most analytics (Google Analytics, Facebook Pixel, TikTok) can defer without breaking. Theme.liquid: add 'defer' attribute to script tags or move to footer. Test purchase flow end-to-end after deferring.
- Audit theme.js. Online Store → Themes → Edit code → assets/theme.js (or global.js in Dawn). Look for known patterns: deprecated jQuery, conflicts with apps. Update theme if outdated.
- Fix cart drawer conflicts. Most common Shopify JS issue. Cart drawer apps (UpCart, Rebuy, Slide Cart) replace the theme's default cart drawer. Theme JS still tries to control cart state. Result: errors or unexpected behaviour. Fix: pick one — theme cart drawer OR cart drawer app, not both.
- Add error tracking. Sentry, Rollbar, or LogRocket. Track JS errors from real users. Many errors only occur on specific browsers or in specific user flows.
Frequently Asked Questions
Why is my Shopify cart drawer behaving unpredictably?
Almost always: two systems trying to control it. Theme has built-in cart drawer; you installed an app that adds another. They conflict on add-to-cart events, quantity updates, drawer open/close. Pick one. If keeping app, disable theme's cart drawer in theme settings. If keeping theme's, uninstall the app.
How do I find which Shopify app is causing INP problems?
DevTools Performance → record an interaction. Examine flame chart. Long tasks (>50ms) show their source script. Map script source to app: cdn.shopify.com = theme; extensions.shopifycdn.com/SOMEAPP = that app. Heaviest apps are typically: chat widgets (Tidio, Gorgias), popup apps, related-product apps.
Can I disable jQuery on Shopify?
Modern themes (Dawn, Sense) don't use jQuery. Older themes (Debut, Brooklyn) often do. Many older apps assume jQuery is present. Disabling jQuery on an older theme/app combination breaks things. Audit dependencies before attempting.
What is 'Reduce unused JavaScript' on PageSpeed for Shopify?
Identifies bundles where most code isn't executed on current page. Common in Shopify because apps load globally even when not used (e.g., cart drawer app's JS loaded on collection pages where there's no cart drawer).
How do I conditionally load app JS only on relevant pages?
Most apps don't expose this control. Some apps have settings to load 'only on cart' or 'only on product'. Otherwise: contact app vendor, or use Asset CleanUp-equivalent for Shopify (Page Speed Optimizer apps). Or accept the JS bloat — Shopify can't fully eliminate it without app architecture changes.