Reducing unused Javascript to improve Core Web Vitals

Reducing unused Javascript to improve Core Web Vitals

Shopify Partner
75 1 13

Hey Shopify Community,
we are running a Shopify Plus store for 2 years now and our main problem is that a lot of functionality only comes with apps or we'd have to custom code them which would take unnecessary resources to do work that already has been done. The main problem with apps is that they inject Javascript into every page, even tho some apps are only needed on specific ones like cart, product, home or content pages.


Therefor we stumbled across a solution from another member @PageFly-Richard (thanks for the hint!) to comment out the {{ content_for_header }} which is definitely a solution, but doesn't let you load specific apps on specific pages.

We spun it further and created rules to strip only specific javascript (apps) on specific pages. The results were satisfying and we decided to release an app doing exactly that.


We are happy for any feedback, improvements, bugs you report. It should definitely help stores with a lot of apps installed.

Reply 1 (1)

Shopify Partner
582 88 110

@Marc_Mayr  you can load scripts where they needed 



{% if template != "index" %}

{% include 'custom.js' %}
{% endif %}


custom.js  will load on every pages except home


{% if template contains 'cart' %}

{% include 'cart.js' %}
{% endif %}


cart.js  will load on cart pages only

▶️ If you need more help with your Shopify store
Speed Optimization | Theme Customization ? ☎️ WhatsApp ✉️Email Skype: