Re: How to Remove Unused Javascript and CSS?

How can I effectively remove unused Javascript and CSS from my store?

Cedcommerce
Shopify Partner
718 76 114

Hey! Geeting of the day to you all hard-working Shopify merchants 

We often encounter a lot of questions about removing unused Javascript or CSS from your store to optimize your store page speed. 

 

To make a long story short, optimizing the load speed of your Shopify store needs technical know-how and experience with handling liquid code. 

 

As most of us are unsure how removing unused javascript works, we will try to address all your doubts and queries concerning removing unused javascript from the Shopify store script.

 

However, for practicing this you must have some basic coding knowledge and must be versed with javascript to follow the below instructions. 

 

Else, you can Inbox our Experts team who can help you completely optimize your page speed at no cost for the first time. 

 

What is Unused Javascript or CSS?

 

Your Shopify store’s front-end code uses a wide range of programming languages like JavaScript and CSS for an interactive user experience. However, it has its implications, adding coding resources in the form of scripts and apps usually comes with performance downgrades on your sore page. 

 

Unused Javascript is the non-critical Javascript that is not used for the content in the webpage.  These are generally left behind after you remove the previously added third-party apps into your Shopify store script. 

 

Note: Don't follow this without a technical background, we suggest you take the help of a technical expert like us.

 

Remove unused CSS and unused Javascript:

 

  • Check the Assets folder of the theme and check for unused JS and CSS files
  • Now remove unused CSS and Javascript files
  • Check and remove the unused apps, if any
  • If your store has not installed any app you can comment {{ content_for_header }} code in the theme.liquid 



To remove unused apps along with the code use scripts under the condition of the theme.liquid file. 

 

For example:- If a script is required to only load on the home page then you need to set a condition like this

 

{% if template == "index" %}

//script goes here

<script src="{{ script link}}" ></script>

{% endif %}

 

To include the script on a product page, use the below-provided code:

 

{% if template == "product" %}

//script goes here

<script src="{{ script link}}" ></script>

{% endif %}

 

To include the script on the collection page, use the below-provided code:

 

{% if template == "collection" %}

//script goes here

<script src="{{ script link}}" ></script>

{% endif %}

 

Note: This is not advised if you don't have knowledge about liquid.

 

The above steps help you remove the unused Javascript(JS) file and CSS files that make your website page script heavier resulting in slower load performance of the page. 

 

Although, removing unused javascript is one of the many processes of speeding up and optimizing your web page speed. You can try other solutions also.

 

If you want to learn more about Optimizing your Shopify store and increasing website speed by upto3x, Connect with us.

 

Hope this solution was helpful. 

 

All the best, 

CedCommerce

CedCommerce || Shopify Expert
- Let us know if our reply is helpful for you. Like it.
- Was your question answered? Mark it as an accepted solution.
- For further discussion contact: Email ID- apps@cedcommerce.com
- Whatsapp:- Join Here
Replies 17 (17)

1080
Shopify Partner
301 9 65

@Cedcommerce  Thanks lot for the valuable answer 

Cedcommerce
Shopify Partner
718 76 114

We're glad it helped @1080, keep growing Cedcommerce got you back.

All the best!  

CedCommerce || Shopify Expert
- Let us know if our reply is helpful for you. Like it.
- Was your question answered? Mark it as an accepted solution.
- For further discussion contact: Email ID- apps@cedcommerce.com
- Whatsapp:- Join Here
1080
Shopify Partner
301 9 65

@Cedcommerce   i have simile query related to the this community question  https://community.shopify.com/c/site-speed/dawn-theme-page-speed-optimization-checklist/td-p/1758904 

i see the some store has mobile speed more then 95 light house score . if you can share here DM me. 

Cedcommerce
Shopify Partner
718 76 114

Hi @1080

Could you please share your store URL so that we can look into it and assist you better?

 

CedCommerce || Shopify Expert
- Let us know if our reply is helpful for you. Like it.
- Was your question answered? Mark it as an accepted solution.
- For further discussion contact: Email ID- apps@cedcommerce.com
- Whatsapp:- Join Here

Bee-Connected
Visitor
1 0 0

@Cedcommerce Could you please help me with this issue since I think when installing apps creates files but removing files doesn't delete the files. Could you assist me in this please. 

Thanks in advance

Cedcommerce
Shopify Partner
718 76 114

Hi @Bee-Connected

For deleting the app files or code, you must follow the step mentioned by the app in their document or FAQ's so it doesn’t affect any other functionality in your website.

 

Let us know if you need any further help from us. 

 

All the best, 

CedCommerce

CedCommerce || Shopify Expert
- Let us know if our reply is helpful for you. Like it.
- Was your question answered? Mark it as an accepted solution.
- For further discussion contact: Email ID- apps@cedcommerce.com
- Whatsapp:- Join Here

3azzzeh
Excursionist
18 0 7

@Cedcommerce 

Dear, I have site speed which is good for Desktop version (80%). However the mobile version speed is 30%. Any idea how can i improve this ?

Azkadenia.myshopify.com

 

Best Regards

Cedcommerce
Shopify Partner
718 76 114

Hello @3azzzeh

 

To improve your Shopify store speed on mobile devices, you need to work on the below-stated website issues:

 

  • LCP(Largest contentful pain) - To resolve this issue you need to remove lazy loading from above the fold section of your website.
  • Reduce unused JS and reduce the impact of 3rd party code - Remove unused JS files from your website.
  • Image elements do not have explicit width and height - Reduce the size of the image lies under this issue.

 

If you need any further help in fixing your website speed on mobile and desktop devices, please let us know. 

 

Regards, 

CedCommerce 

CedCommerce || Shopify Expert
- Let us know if our reply is helpful for you. Like it.
- Was your question answered? Mark it as an accepted solution.
- For further discussion contact: Email ID- apps@cedcommerce.com
- Whatsapp:- Join Here
Roughedge
New Member
6 0 0

Can you help me with my speed?

Serhatcal
Visitor
2 0 0

Hello, Thank you for detailed information.

Could you also help me out about the same topic?

here is my url: https://gadroots.com

Roughedge
New Member
6 0 0

Hi my store is roughedge.com.au   can you help me please. i have lots of unused codes left by deleted apps. thanks

jessieclair
Visitor
1 0 0

Hello, We are currently having this issue and would love your assistance!

 

Our site is www.jessieclairactive.com

Cedcommerce
Shopify Partner
718 76 114

Dear @jessieclair,

 

Thank you for reaching out to us regarding your issue with removing unused JavaScript and CSS. Your concerns are important to us, and we would be more than happy to assist you!

 

To better understand your specific situation and provide you with the most effective solution, we kindly request you to connect with our dedicated team of experts who can guide you through the process of removing unused JavaScript and CSS from your Shopify store.

 

You can share your email or contact us through the Shopify Community messaging system. Once we receive your message, we will prioritize your request and respond promptly.

 

We look forward to assisting you and resolving your issue.

 

Regards,

CedCommerce

CedCommerce || Shopify Expert
- Let us know if our reply is helpful for you. Like it.
- Was your question answered? Mark it as an accepted solution.
- For further discussion contact: Email ID- apps@cedcommerce.com
- Whatsapp:- Join Here
Serhatcal
Visitor
2 0 0
Hi,
Thank you for your email. This is my email address: serhatcal84@gmail.com
Where should I start with? to get help
Thank you,
Sincerely
serhat

AtelierLAModa
Visitor
1 0 0

Hello, We are currently having this issue and would love your assistance!

Our site is https://www.atelierlamoda.com/

Our e-mail: lamodaatelier@gmail.com 

We really need your help.

Thanks so much.

Modista y deseñadora
Anastasiia Ladanova

MEDANZ
Visitor
3 0 0

Hi there, I have identified that I have a lot of unused code stemming from an uninstalled app (Zify Gallery) can I just delete the whole asset in my code? There is a .css file and a .js file? Total novice here 🙂

Stelle
New Member
5 0 0

Hi, I'm Stelle from A.A.Y Fashion, our speed score is 36.

One of the reasons for this low score is the use of an App called automizely.com that collects e-mail subscriptions. PageSpeed insights suggests to split the javascript but I have never done this before? I read your suggestion to Inbox the Experts team who can help you completely optimize your page speed at no cost for the first time. Can you please tell me how to contact them? Thanks upfront,

Stelle

https://aayfashion.com/