Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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. https://apps.shopify.com/pagespeed-javascript
We are happy for any feedback, improvements, bugs you report. It should definitely help stores with a lot of apps installed.
@Marc_Mayr you can load scripts where they needed
ex:
{% 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
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025