Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi, can anyone offer some advice on how to reduce unused javascript? I'm having issues with my coreweb vitals and mobile site speed. How do I remove the assets/vendors file (in screenshot) (cdn.shopify.com/s/files/1/0197/8160/t/55/assets/vendors.js?v=11282825012671617991659813677)
and is there a risk of it negatively effecting site once removed?
Many thanks for any advice.
Jo
Prettylittlepartyshop.co.uk
Hello @Jo_Williams1,
We are happy we could help you with this problem.
It’s an essential way to increase your page speed score. We will definitely help you with this.
For reducing the unused javascript, you need to follow these instructions:-
(Note: You are advised to obey this solution if you are technically sound and have knowledge of liquid code)
Remove unused apps along with the code
Use scripts under the condition of the theme.liquid file.
For example:- if a script is needed to load on the home page only then you need to set a condition like this
{% if template == "index" %}
//script goes here
<script src="{{ script link}}" ></script>
{% endif %}
for including script on product page then use this code:-
{% if template == "product" %}
//script goes here
<script src="{{ script link}}" ></script>
{% endif %}
for including script on collection page then use this code:-
{% if template == "collection" %}
//script goes here
<script src="{{ script link}}" ></script>
{% endif %}
Let us know if it works, or if you need more help with this.
You can also check the below link to find a more detailed solution to the issue.
https://community.shopify.com/c/site-speed/how-to-remove-unused-javascript-and-css/td-p/1740699
All the best,
CedCommerce
Hi thanks very much for responding. I've checked out your solutions page and there are some very helpful tips thank you. I am completely new to this but Google lighthouse says I need to delete unnecessary third party code and suggests vendors.js. Can I delete the whole file or do I need to keep it? To me it simply looks like a license code a something?
I'm very grateful for every piece of advice, can I safely just delete vendors.js?
Many thanks
Jo
Hi Joy, I am having similar issues with my own store and checking your store in pagespeed all I can say is WOW massive speed upgrade!! Can you share what you did to make such a massive improvement in speed? Did you end up deleting the vendors.js file? Many thanks in advance.
No I didn't delete the files as advised against it. In the end I just removed all apps and stripped back page content. What is your store?
@Jo_Williams1 we have created an app to solve that exact problem: https://apps.shopify.com/pagespeed-javascript?locale=de
It allows you to remove unused javascript from your Shopify store.
https://www.flash-speed.com/ for a full feature overview.
What do we put in //script goes here the whole script?
{% if template == "product" %}
//script goes here
<script src="{{ script link}}" ></script>
{% endif %}
Hello @Jo_Williams1,
Gina here from flareAI.
If you use less JavaScript on your page, it will reduce the load time of your site.
1. Remove all Shopify apps which you are no longer using
Remove the Shopify apps to avoid running code for unused features, and makes your theme code easier to read.
2. Remove third-party JS scripts which you are no longer using
Consider removing code that was added as part of the app install process. To reduce the size of your codebase, you can use optimization techniques such as removing unused functions or variables.
3. Disable theme features you don't use as themes contain CSS, JS, HTML which can increase and affect your store speed
4. Use minified CSS and JS files
Hope this helps,
Gina
flareAI: Generate Sales from Google Search, on Autopilot
Hi in the end, I rebuilt our website based on the latest version of the Dawn theme. It fixes all of the speed issues, js issues and just loads much faster. I appreciate that may not be an easy solution for you but ultimately speed matters as you get more traffic and more conversions.
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025