Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We have A LOT of unused code slowing down our site. Using dev tools, I can see all the code not being used, its almost all in the index.js. Can I just delete it or will that mess something up?
Thanks!
Solved! Go to the solution
This is an accepted solution.
Your are asking if you can just delete index.js, right? I don't know your site's URl or theme or know what is in index.js so I can't give you specific advise on that.
If PSI says 90% of index.js is not being used, it is possible there is still 10% of that code doing something, like currency changing or whatever.
It is also possible that in the future you might want to enable a feature that is not currently being used, or that there are features that only activate for certain users and thus are not activating for pagespeed insights. So I would reccomend not deleting index.js and instead carefully going through index.js and refactoring the code to conditionally load code depending on what features are on the page using dyanmic imports (if you don't care about IE 11 users, which you shouldnt)
This is an accepted solution.
Your are asking if you can just delete index.js, right? I don't know your site's URl or theme or know what is in index.js so I can't give you specific advise on that.
If PSI says 90% of index.js is not being used, it is possible there is still 10% of that code doing something, like currency changing or whatever.
It is also possible that in the future you might want to enable a feature that is not currently being used, or that there are features that only activate for certain users and thus are not activating for pagespeed insights. So I would reccomend not deleting index.js and instead carefully going through index.js and refactoring the code to conditionally load code depending on what features are on the page using dyanmic imports (if you don't care about IE 11 users, which you shouldnt)
I'd have to agree with @oreoorbitz answer. Even though there may be a ton of unused code coming from index.js, some code is being utilized within that file or potentially on other pages.
Deleting the file will likely cause errors and remove/break whatever functionality is coming from the 10% of utilized index.js code.
The best solution is to manually go through your index.js file (only recommended if you're familiar with code, if not, I'd hire a developer) to see what blocks of code could be removed and which need to stay. Unfortunately, there's not a simple solution for this issue.
Best of luck!
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