Re: How to clear unused code ?

How can I remove unused code after uninstalling apps?

TattooKits
Tourist
11 0 3

I found that after uninstalling the apps, the page will have a lot of unused code, affecting the speed of the page. Is there any apps that can clear all unused code of the website?

Replies 229 (229)

Perennial
Shopify Partner
1468 114 234

Unfortunately, there is no app in Shopify that does this work of clearing out the code.

However, we can certainly help you in removing the unused code from uninstalled app if you can provide more details to it.

 

Looking forward to hearing from you.

 

Thanks & Regards,

Perennial Solution

MC_OnEx
Excursionist
12 0 5

i have the same problem causing major problem in my store. why are these apps not required to remove all there code when the app is deleted. people should be warned about this before adding any apps. is there any tool out there to identify the location of unused code. i can delete the code if i know what file its in and how to identify the code.

 
Remove unused CSS
 
2.2 s
 
Remove dead rules from stylesheets and defer the loading of CSS not used for above-the-fold content to reduce unnecessary bytes consumed by network activity. Learn more.
 
 Show 3rd-party resources (3)
                                                            
 
             URL                                      Size        Potential Savings
 
…admin/style-6eaaa8d….css
(cdn.shopify.com)                        195 KB     194 KB
                                                          
…assets/theme.scss.css?771
(cdn.shopify.com)                         17 KB     13 KB
                                                     
…assets/beans.css?771
(cdn.shopify.com)                       2 KB       2 KB
 
 
Perennial
Shopify Partner
1468 114 234

Sorry but there are no tools available for identifying the unused code after deleting the app.

hob_colombia
Visitor
1 0 0

I need serious help with this, at the beginning of my store I was just testing out a bunch of apps. Now my website is really slow and since Shopify has no app history or anything how can I tell what to delete or remove or even get help on. I need someone that can scan my theme for me or tell me what to delete.

OliUK
Shopify Partner
235 2 56

Hi @hob_colombia ,

If you post your URL I will have a quick look for you. Otherwise you could use 'Lighthouse' in Google Chrome Inspector.

Cheers,

Oli

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

Lelemadethis
New Member
4 0 0

Hi @OliUK 

Will you please have a look at my website, www.lelemadethis.com ? 

Scoring quite low on the mobile rankings on Google pagespeeed and i'm really out of ideas how to fix it 🙂 

Cheers, 

 

OliUK
Shopify Partner
235 2 56

Hi @Lelemadethis ,

Facebooks the biggest 'unused Javascript' source.

But I might have found something else, your store downloads the whole of Jquery (which is a big Javascript framework). I've seen this before requested by store themes, but your theme doesn't seem very Javascript heavy.

If you go to your theme files, there's a file called 'app.js' with it in. Tread with caution though, there is every chance this file is in use and I just don't know where. 

I would:

  • Duplicate your theme
  • Remove said file from duplicate theme
  • clear browsing data from your browser
  • Then test all of your website pages/cart etc
  • If it all looks good, switch to this duplicate theme without the file.

Hope that helps,

Oli

 

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

Lelemadethis
New Member
4 0 0

Thanks Oli for your reply. 

 

Unfortunately, i could not find that app.js file, i did found a file called app.js.liquid which broke the website when deleted 🙂

OliUK
Shopify Partner
235 2 56

Hi @Lelemadethis ,

Ah yep, testing these things before making the change is so important. 
It sounds like that file is in use which is a shame.

Apart from that, your site seemed fairly well optimised. It must be the theme mostly slowing it down.

Cheers,

Oli

 

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

 

 

johnC1
Tourist
8 0 3

Hi guys, 

Does anyone have any tips for speeding up this site? 

www.plakatbar.no 

In GtMetrix I get: 

467.3KiB of JavaScript is parsed during initial page load. Defer parsing JavaScript to reduce blocking of page rendering.

 

I see that some of these comes from old apps, not innstalled anymore. But how do I find those snippets of code? 

 

 

Gigi0ne
Tourist
8 0 4
Click to expand...
hi.. apologise for my english



i use this on theme.liquid to delete the amazonaws on my site


{% capture h_content %}
{{ content_for_header }}
{% endcapture %}

{% if h_content contains "amazonaws" %}
{{ h_content | remove: ',"https:\/\/s3.amazonaws.com\/lastsecondcoupon\/js\/eventpromotionbar.js?shop=milanobags-romania.myshopify.com"' }}
{% else %}
{{ content_for_header }}
{% endif %}

try add more {{h_content|remove..................."}}

i hope help...

preventtek
Tourist
4 0 1

You won't find an answer. They are doing nothing about it.

OliUK
Shopify Partner
235 2 56

Hi @preventtek ,

If Shopify provided the barebones of a web page with plain text and a list of products with a buy button, that would be very fast.

However, store owners want and desire more than that, whether it's stylistic or functional, millions of store owners require different elements and functions for their online business. It would be impossible for Shopify to build for all of these use cases. Hence, why they have a third-party appstore and theme eco-system.

Shopify actually has a pretty in-depth vetting process for third-party apps now, I heard recently about an app taking 6 months before they allowed it through. It might not have always been this way, but it is now and they do care. (That said, there are certainly irresponsible apps out there and it can be very frustrating.) 

It sounds like you have some apps slowing down your page speed, would you like me to have a look for you and see If I can point you in the right direction? Just post your URL and I'll have a look.

Cheers,

Oli

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

OliUK
Shopify Partner
235 2 56

Hi @johnC1 ,

I would test removing anything before you remove it on your live site (through duplicating the template and previewing it).

If you have removed these apps, then they must be getting triggered from a file in your theme.

1. Check in your theme folder and then 'js folder' => 'modules' and check that folder for 'frequently bought together'. If that folders there, that's the culpret.

For the others, I would recommend downloading your entire theme, then using a program like 'TextMate' to search the entire folder for the app name. Once found, I would then experiment with removing that block of code.

The third (and possibly fifth) URLs in your list are from your the theme, so shouldn't be tampered with.

Good luck,

Oli

 

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

johnC1
Tourist
8 0 3

Thanks Oli! 🙂 

CONOR3
Tourist
6 0 2

Hi Oli,

Any tips would be great as speed is really bad on mobile but great on desktop. 

 

Any advice how we could improve the mobile speed?

 

https://pappedpets.com/

 

Thanks

OliUK
Shopify Partner
235 2 56

Hi @CONOR3 ,

Just had a quick look at your store.

You've got quite a couple of quite large-sized images like the main phone case shot. It would be idea to add lazy loading too these, which can be done by adding 

loading="lazy"

to any image tag i.e:

<img loading="lazy" otherstuff="this and that" etc >

 or try and downsize the image size a bit, there's one currently at 700kb, which could probably be around 200kb.

Facebook takes up quite a bit of time, also there's quite a few requests from your theme taking up time. There's a product options app that blocks load time for 800ms when the customer first lands on your site too (I think).

Hope that helps,

Oli

 

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

jtan
Trailblazer
158 4 24

hi Oli, 

 

as with everyone else im having a bit of trouble with load speed for mobile. 

Desktop seems to be fine but my mobile speed is terrible. 

Any pointers on how to speed the site up. 

 

website is: Thetinycrate.com.au

 

Thanks

 

Jess

OliUK
Shopify Partner
235 2 56

Hi @jtan ,

Yep, no worries. Your site loads super fast on my Mac by the way, like 1/2 a second type fast.

The biggest opportunity to remove unused Javascript is coming from an app, it might be a wishlist app, I'm not quite sure. Here's the entry:

164.6 KB
128.7 KB
 

 

After that, the big requests are all from your theme or Facebook.

Hope that helps,

Oli

 

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

jtan
Trailblazer
158 4 24

Hi Oli,

 

Thanks for your reply. 

 

Are you getting those same speeds on your mobile phone?

 

It seems like the desktop site is working well but the mobile site might be slow. 

 

Thanks

 

Jess

OliUK
Shopify Partner
235 2 56

Hi @jtan ,

I haven't tried on my phone but my guess would be no.

I suppose the most common causes of sub-par speed are:

  1. Over-sized app files/requests
  2. Un-optimised image files (without lazy-loading)
  3. Big theme requests.

Number 3 is tricky to optimise as themes are quite complex and easy to break. Numbers 1 and 2, you could focus on though (with the app in my last reply being a good place to start).

Cheers,

Oli

 

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

revolutionnaire
Visitor
1 0 0

Hi Oli,

Google identified 5s worth of unused javascript code. How I go about clearing this?

 

3.8 KiB
930 ms
54 KiB
1,980 ms
31.7 KiB
1,680 ms
1 KiB
780 ms
8 KiB
1,080 ms
102 KiB
2,280 ms
/app.js
(shopoe.net)
0.6 KiB
780 ms
OliUK
Shopify Partner
235 2 56

Hi @revolutionnaire ,

The 3rd, 4th, 5th and 6th lines are requests from your theme I think (so you shouldn't really tamper with them).

The 1st and 2nd lines of code are coming from an 'also bought'/product recommendation app. The first request is for a big Javascript library, the second is for a pretty small Javascript file. I would guess they're both essential to the app running. If you don't currently use this app, I would recommend googling how to remove that specific app's code. If there's nothing in Google, then I'd suggest emailing the developers.

The last request is for a single line of code, but the server does take a little while to respond. I don't know what the apps called, but if you open Google Chrome, load your website and then the 'Inspector', then click 'Console' in the top menu, and type:

document.getElementById('beappjs-wrapper-ct').style.display = 'none';

That command will hide the app's widget from your product/collection page (if it's there) which will tell you where it's coming from and if you use that app currently. I would suggest trying a couple of different pages until you find it. 
If you're not currently using the app, you can then search for the word 'beapp' or the name of the app in your theme's code and remove the the line of code containing it. (although I would duplicate your theme and test this before making the change live.

Cheers,

Oli

 

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

OliUK
Shopify Partner
235 2 56

Hi @Rich2727 ,

Thanks for the kind words. Happy to have a quick look at your store.

Your store loads pretty fast for me actually and the only large request Google mentions that's slowing down your initial page load is your theme's stylesheet. So, nothing we can really do there.

In the 'Remove unused Javascript' section there's quite a few requests from your theme, but there are also three different requests from Google Tag manager, with two different id codes. Is there any chance you've got Google Tag Manager installed twice? This could be a way to increase your score a little (it might be listed twice in the <head> section of the theme.liquid file in your theme's folder) .

In general though, your store runs a lot faster for me than I'd expect, given the Google speed test score.

Cheers,

Oli

 

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

Daryl_SSW
Visitor
2 0 0

Hi @OliUK 

any chance you could help me with possible speeding up my site?

https://www.southwestslates.co.uk/

I'm unsure what many of the issues are when checking the score, but it seems quite low!

Many thnaks,

Daryl

OliUK
Shopify Partner
235 2 56

Hi @Daryl_SSW ,

Yep, sure.

The Google report mentions that you haven't got lazy loading for your images. Lazy loading comes with a lot of themes out the box, but it's quite easy to add in manually. You just need to add this attribute to any <img> tag: loading="lazy" 

i.e.:

 

<img id="something" src="something-else" loading="lazy">

 

Also, Google mentions these requests are slowing down your page load:

URLTransfer SizePotential Savings

36.6 KiB
1,110 ms
5 KiB
150 ms
21.8 KiB
300 ms
85 KiB
1,680 ms

 

The top ones from your theme, so can't really be helped. The bottom one looks pretty substantial, maybe get in touch with the developers if you're still using the app and ask what can be done to speed things up.

Good luck

Oli

 

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

Daryl_SSW
Visitor
2 0 0

@OliUK  Thanks for the reply.

So would that mean adding that code to every image on the site? Do you offer a service or know of an app that does this for you?

I'm unsure which app that is, I'm not sure I've even added an app from Gravity-apps!

Cheers,

Dary

OliUK
Shopify Partner
235 2 56

Hi @Daryl_SSW ,

Well it would mean adding that code to every template file in your theme, i.e. adding it just once for the product page template would mean all of the product pages get it.
I don't offer such a service, just because my Shopify app keeps me at capacity. I'd say any web developer could do it no problem though, junior etc.

Yeah, I know what you mean. The publisher name often isn't much of a clue. I had another look and if you search 'Change Image On Hover Effect' on the Shopify appstore, it should come up. They look small-ish, so I'm sure they'll be happy to help.

Cheers,

Oli

NazSaveCo
Shopify Partner
10 0 1

Hi Oli,

 

Could you please take a look at savecobradford.co.uk? 

 

Kind regards

Naz

OliUK
Shopify Partner
235 2 56

Hi @NazSaveCo ,

Yep, sure. Your images seem to all be well optimised etc, which is super important for a store with so many SKUs like yourselves.

The biggest request is from your theme (I think), followed by Facebook.
However, after that it's followed by a chat app, that you could remove if you're not using.

Apart from that, it's a lot of small requests, a lot coming from Google tag manager, Analytics and AWS.

142 KB
115.5 KB
132.4 KB
113.9 KB
/5ea09c3…/default
(embed.tawk.to)
222.6 KB
106 KB
64.8 KB
55.6 KB
60.6 KB
52.6 KB
…3.3.1/jquery.min.js
(cdnjs.cloudflare.com)
58.4 KB
39.8 KB
54.5 KB
39.3 KB
64.3 KB
39 KB
51.4 KB
37.3 KB
…2.2.4/jquery.min.js
(ajax.googleapis.com)
59.1 KB
36 KB
…1.11.1/jquery.min.js
(ajax.googleapis.com)
65.4 KB
34.2 KB
…2/loader.js?t=2020828
(sdk.loyaltylion.net)
52 KB
33.5 KB
/en_US/fbevents.js
(connect.facebook.net)
67.4 KB
31.4 KB
29.7 KB
26.2 KB
36.1 KB
24 KB
61.2 KB
23.1 KB
43.7 KB
20.1 KB
26.2 KB
17.4 KB
31.7 KB
15.5 KB
25.5 KB
14.3 KB
22.2 KB
14.1 KB
30.7 KB
12.4 KB
13.3 KB
8 KB
18.6 KB
7.7 KB
8.7 KB
6.9 KB
14.1 KB
6.7 KB
…v1/messages.js?app_id=…
(sdks.automizely.com)
12 KB
6.7 KB
…v1/5.fc159625.js
(sdks.automizely.com)
12.5 KB
6.1 KB
9.3 KB
5.8 KB
6.9 KB
5.7 KB
…external/app.js
(cdn.shopify.com)
5.7 KB
4.8 KB
11.9 KB
4 KB
…v5/tp.widget.bootstrap.min.js
(widget.trustpilot.com)
6.8 KB
3.7 KB
4.4 KB
3.3 KB
/limits/meatandco.myshopify.com?v=…
(shopifyorderlimits.s3.amazonaws.com)
8.8 KB
3 KB
/tp.min.js
(invitejs.trustpilot.com)
4 KB
2.5 KB
6.7 KB
2.5 KB

 

Cheers,

Oli

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

 

lavinia13
New Member
4 0 0

hi Oli!

I'm even seeing a very low score on my store both on the shopify speed meter and on google insights. Could I bother you to take a look? I'd really appreciate any advice!

https://adkn.co.uk

OliUK
Shopify Partner
235 2 56

Hi @lavinia13 ,

Yep sure, no worries. Nice site by the way.

You have a really big request coming from a loyalty rewards program app beginning with 's'. There's another smaller request coming from them too.
I'm aware of these guys and they produce a really polished product. Maybe reach out to them and quote the below, they might be able to offer help on how to optimise things.

URLTransfer SizePotential Savings

/v1/vendor-ce3bc1a….js
(smile-ui.smilecdn.co)
208.2 KB
167.8 KB
179.5 KB
129.1 KB
107.6 KB
80.9 KB
87 KB
66.1 KB
/v1/smile-shopify-8e18f34….js
(smile-ui.smilecdn.co)
90 KB
63.1 KB

 

You can see another third-party app request in the third row. If you're not using the app, then removing that code from your theme would help a bit too.

Good luck,

Oli

 

——————————

Founder @ www.preproduct.io
Test and make sales for future products

 

 

 

atienzza
Visitor
1 0 0

Hi Oli!

Can you take a look on my site as well? I started selling again after some months and the score changed from 34 to 6. I supose that is because of Printful and CJDropshipping Apps, but I think the change is to heavy to only adding those.

This is my landing page :  https://atienzza.com/products/love-lamp

Thanks in advance and have a nice day!

Alejandro

OliUK
Shopify Partner
235 2 56

Hi @atienzza ,

Yep sure, no worries.

I've pasted Google list of processes with unused Javascript below.
The top spot and biggest by far is coming from your assets/app.js folder. There's a big chance this is a theme file and would break your store if removed. Still, might be worth looking into incase it isn't.

The second request in the list is to an old Shopify framework for theme building (the last official release was 4 years ago). This is in the assets folded roof your theme too and might be worth looking into. The rest of the requests aren't too big to be fair.

I used to have a customer with the same theme as you and it's pretty heavy duty and probably causing a lot of the page speed concerns. Still, the timber.js request might not be coming from it, so I would start there.

URLTransfer SizePotential Savings

301.9 KB
206.3 KB
104.2 KB
67.5 KB
69.4 KB
54.6 KB
68.3 KB
51.7 KB
61.2 KB
24.3 KB
25.7 KB
14.4 KB
30.9 KB
13.3 KB
59.1 KB
12.7 KB
22.2 KB
12.5 KB
/en_US/fbevents.js
(connect.facebook.net)
29.6 KB
7.1 KB
18.6 KB
7 KB
18.1 KB
6.8 KB
14.9 KB
6 KB
4.1 KB
2.8 KB
6.1 KB
2.5 KB
25 KB
2.3 KB

 

Cheers,

Oli

——————————
Founder @ www.preproduct.io
Test and make sales for future products

 

 

Jack-D
Visitor
2 0 0

Can you help me out with this same problem?


@Perennial wrote:

Unfortunately, there is no app in Shopify that does this work of clearing out the code.

However, we can certainly help you in removing the unused code from uninstalled app if you can provide more details to it.

 

Looking forward to hearing from you.

 

Thanks & Regards,

Perennial Solution


 

preventtek
Tourist
4 0 1

That is very unfortunate, and what is more unfortunate is that you are so nonchalant about admitting you have no tools to prevent the inadvertent degradation of your own product and that you seemingly don't care about providing a solution. I will be cancelling my subscription shortly due to this attitude your company has. It is particularly disturbing that you would allow 3rd parties to corrupt our sites and do nothing. Then, you have the audacity to ask for more money, so people on the back end can do what they should be doing to begin with at NO extra charge to the customer. This is supposed to be what we are paying for on a monthly basis.

brunashaqiraj
Visitor
2 0 0

Hello , 

 

I'm having the same problem with this unused codes , please can you help me with that?

OliUK
Shopify Partner
235 2 56

Yeah, no worries @brunashaqiraj , post your site URL and I'll have a quick look.

 

 

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

brunashaqiraj
Visitor
2 0 0

Thank you so much.

 

Here it is: www.shop.christinevalmy.com

OliUK
Shopify Partner
235 2 56

Hi @brunashaqiraj 

I don't think your sites that slow to be honest mate. The top loading times other than Shopify stuff looks like Google leads and there's also a failed request to this URL: https://unpkg.com/eventemitter3@4.0.4/umd/eventemitter3.min.js to get come javascript, this might be important for elsewhere on your site though.

Cheers,

Oli

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

 

mjfitness
New Member
5 0 0

Hello

 

Can u check my site speed, please?? And help me remove all the trash codes? Thanks

 

www.mjfitness-store.com

OliUK
Shopify Partner
235 2 56

Hi @mjfitness ,

You have some images not using 'lazy loading', check back through this thread for instructions on implementing this.

The rest doesn't look too bad, only your stylesheet is listed in 'render-blocking resources', so no real work to do there.

The 'remove unused Javascript' section of Google's report contains the below requests. This isn't really as important as the 'render-blocking resources', but you can look into them if you would really like to improve your score

 
 Show 3rd-party resources (9)

URLTransfer SizePotential Savings

355.3 KiB
205.1 KiB
165 KiB
93.6 KiB
137 KiB
61.1 KiB
80.1 KiB
49.8 KiB
139.8 KiB
48.2 KiB
51.4 KiB
36.3 KiB
96.9 KiB
34.1 KiB
…1.10.2/jquery.min.js
(ajax.googleapis.com)
34.8 KiB
22.9 KiB
54.7 KiB
20.1 KiB

 

Cheers,

Oli

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

mjfitness
New Member
5 0 0

Thank you for your response. I am not a programmer to know how to do them. Can u pls help?

OliUK
Shopify Partner
235 2 56

Hi @mjfitness ,

Unfortunately, I don't have the time to action the changes, just to give feedback. I'd recommend the Shopify Partners network, or you could even look into some of the cheaper freelancer websites (Upwork, Fiverr etc) and just look for a Shopify developer (Ruby on Rails or WordPress developer would probably be fine too). Then pass on the feedback I mentioned.

Good luck,

Oli

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

MamaMilla
New Member
7 0 0

Hi OliUK

I really appreciate that you are spending so much time helping strangers!

I recently installed the Flex theme from Out of the sandbox and im getting a speed of 17 on my page www.mamamilla.dk

Could you, when you have the time, try and see if there are any low hanging fruits for me to pick up the speed. Im seeing loads of URLs(almost all) with LCP/CLS issues in Google Search console, and I have no clue how to fix it.

Thanks in advance 🙂

Bruno

OliUK
Shopify Partner
235 2 56

Hi @MamaMilla ,

No worries at all Bruno.

I would suggest looking through your 'theme.liquid' file, after the '<head> and before the '</head>'. Just to make sure there's no apps/services mentioned in there that you don't use anymore. It will probably look something like 'include app_name'. 

In the report, a loyalty app comes up, as well as a couple of requests to coding libraries (Jquery and Fancybox). The coding libraries are tricky to figure out where they're being initiated from and if there still in use, I'm afraid.
It might be worth researching your Shopify theme, to see if anyone else is experiencing slow page speed. The theme can make a huge difference.

Good luck,

Oli

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

KrisMcD
Visitor
3 0 0

Hi @OliUK, I saw that you were able to help a lot of people with the site speed of their website and was wondering if you could do the same thing with mine?

 

My store's name is www.cbdpile.com and the speedscore was hovering around 19. I was able to pinpoint some things I was able to remove to bring it up to around 33 but I was hoping if you could identify a way for me to remove the third-party code or unused JavaScript? 

 

Specifically I see that the gstatic.com recaptcha and styles is causing the website to run slow. Is this something that can be removed?

OliUK
Shopify Partner
235 2 56

Hi @KrisMcD ,

Yep sure, no worries.

It can be tricky finding where the request is initiated from. There's a 'request initiator chain' section in the 'network' area of Google lighthouse, but I still can't work out where the Recaptcha request is coming from.

I'd recommend looking through your apps, as well as the <head> section of your theme.liquid file. If you still can't find a mention of the recaptcha, you could download your theme's code, then use a free coding editor like TextMate's 'find in project' tool to search through the entire folder for 'recaptcha' or a similar keyword to try and work out where it's coming from.
As always, consider testing any removal you make as it might have adverse effects.

For the styles, this is harder. Unless it's styling from an unused app, I wouldn't recommend editing any stylesheets. It just gets complicated and easy to make a mistake.

Good luck,

Oli

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

KrisMcD
Visitor
3 0 0

Sounds good, thank you so much for your advice!