New Member
2 0 0

Hi all, I'm a bit stumped here and could do with some help if at all possible. Through PageSpeed Insights I've got a ton of unused JavaScript I just can't seem to rectify. Any help would be much appreciated. 


Shopify Expert
1195 106 290

To remove unused javascript, here's the path I usually take:

1) Remove any old app code (when you delete an app it loses access to your store, so it can't clean up after itself if it added code to your theme). You can usually find most of this in theme.liquid. You can also look at all the requests loaded (like in your screenshot) to help identify if any of the resources are from apps you no longer use.

2) Next up, for any resources that you have control over, you'll want to conditionally load them to where they're needed. For example, if you have an app / resources that are only needed on the product page but loaded on every page (from theme.liquid) wrap them in a Liquid statement to only load them there:

{% if template contains "product" %}
  put any code for product pages only here
{% endif %}

3) It's not practical and rarely a positive ROI in my opinion, but next up you can dissect theme files that contain code for all templates, and separate into separate files so you can load them conditionally (as in step 2). For example, you could split vendor.js into vendor-globla.js, vendor-home.js, vendor-product.js, etc.

You'll still likely end up with warnings because you don't have access to 3rd party app code. The estimated savings of 4.89s is not realistic. In actual cases, by removing some code it might help load speed a little, but not by much, definitely not something you would notice.

Founder of Speed Boostr (Shopify optimization experts, theme customization, custom app development).
Creator of Shopify Analyzer (first performance analysis tool for Shopify sites, free for the Shopify community).
Creator of Order Automator (auto tag orders and customers + auto fulfill orders + email notifications).
Creator of Theme Scientist (A/B testing app) and Tip Jar (add a tip button to your store).
New Member
2 0 0

Hi, thank you for taking the time to respond and help. I will certainly look into these this evening.