I review a lot of Shopify stores each week.
One thing that comes up time and time again is old code lying around from apps that have been uninstalled.
For back office only apps like my Repeat Customer Insights that don't touch the storefront, uninstalling is simple and clean. It's rare that code gets left behind.
But for apps that have to be in the storefront, visible to customers, or that need theme edits, things get tricky.
Sometimes this code is useful to keep around post-uninstall (like in JSON-LD for SEO's case) or sometimes the code doesn't run after the app is removed, but other times it can cause problems.
The reason Shopify apps leave old code around is because of how Shopify works when you uninstall an app.
From the moment an app is uninstalled in Shopify's admin area, Shopify blocks the app from doing anything in your store. That means apps aren't given the chance to cleanup or remove anything even if they wanted to.
Shopify's recommends using things called ScriptTags but that's only for JavaScript, it doesn't support Liquid. (Don't worry what ScriptTags actually are, they are a developer thing an app can use)
Some features just can't work using JavaScript either. JSON-LD data added via JavaScript is rejected by Merchant Center and adding visible things using JavaScript causes a delay and jerkiness that customers can see.
Plus JavaScript and ScriptTags are the #1 source of major site performance problems in Shopify (e.g. loading 99 versions of the same JavaScript code, slow app servers slowing down stores).
There really isn't a good solution to this problem.
The best one I've found is two-fold:
- apps need to provide easy to find and clear directions on how to clean things up after uninstalling
- you and your team need to remember to find and follow the full uninstall directions
It might also be a good time to give your store a spring summer cleaning and ask your theme developer to double-check for any stray code.
Eric Davis