How to Identify and Remove Unused JavaScript for Better Site Speed?

Hello everyone,

I am looking for advice on optimizing my Shopify store’s speed. Specifically, I would like to know:

  • How can I identify unused JavaScript code on my site?

  • Are there any recommended tools or methods for finding and removing leftover code from apps?

If you have experience with this or any insights, I would greatly appreciate your guidance. Thank you in advance!

Hi @fatemeh

Here are some ways that you can identify and remove unused Javascript:

  • Use Google PageSpeed Insights or Lighthouse – These tools highlight unused JavaScript and CSS, helping you pinpoint problem areas.
  • Manually audit installed apps – Some apps inject scripts even after uninstalling. Check Online Store > Themes > Edit Code and look for leftover app code in theme.liquid or snippets.
  • Try a Shopify speed optimization app – Apps like TinyIMG or Page Speed Optimizer can help streamline performance.

Hi , @fatemeh

Unused JavaScript is a pretty common reason for slow stores, especially after trying out different apps over time.

  1. Identify unused JavaScript
  • Run your site through PageSpeed Insights
  • In DevTools: Inspect ⇒ More tools ⇒ Coverage ⇒Reload the page .This will show how much of each JS file is actually used vs unused
  1. Remove leftover app scripts (biggest impact) :
  • Go to Online Store ⇒ Themes ⇒ Edit code

  • Open theme.liquid and look for

  • Check theme.liquid, theme.js, global.js, and app snippets

  1. Defer non-critical JavaScript :
    If a script isn’t needed immediately, add defer .This lets the page load first before running the script.

  2. Check App Embeds

  • Go to Customize ⇒ App embeds
  • Disable any apps that are not in use
  1. Test changes

Duplicate your theme, make changes step by step, and recheck Google PageSpeed Report.

Focusing on unused JavaScript and app scripts usually delivers the biggest performance gains.

Cleaning up unused scripts should improve load times. You can also use tools like Website Speedy shopify app, but it’s entirely optional to use.

Disclaimer : I’m affiliated with the Website Speedy .
Hope this Helps!