How to avoid loading irrelevant JS files in Shopify in 2025?

Topic summary

A Shopify store owner reports a significant drop in Lighthouse performance scores (from 90+ to 60-70) due to Shopify automatically loading numerous JavaScript files that are irrelevant to their store. Examples include payment processors (Prime, Google Pay) and analytics tools (Rage Click) they don’t use.

Technical Issue:

  • Previously used Liquid code to selectively remove JS files from non-product pages by capturing and modifying content_for_header
  • This workaround no longer functions, suggesting Shopify may have removed the ability to manipulate this header

Response Provided:
A community member suggests that Lighthouse scores don’t fully reflect actual store performance, noting acceptable benchmarks are 50 (mobile) and 80 (desktop). Recommended optimizations include:

  • Minimizing third-party apps
  • Reducing content density per page
  • Avoiding external libraries like jQuery

Status: The question about preventing irrelevant JS files from loading remains unanswered, with no confirmed workaround for the broken Liquid method.

Summarized with AI on November 2. AI used: claude-sonnet-4-5-20250929.

I periodically try to optimize our Lighthouse page speed score and previously managed 90+ scores for all our pages. Since then, however, Shopify has introduced a ton of new JS/CSS files that load and seem to reduce all our page scores to the 60-70 level.

See e.g. the below screenshot of a number of JS files that are completely irrelevant to us (we e.g. do not use Prime, Google Pay, Rage Click and whatever all the other stuff is):

In addition, I could previously use a liquid script ala below to remove JS files from loading on e.g. my non-product pages - but this no longer seems to work, as if Shopify potentially removed the ability to capture the content header at all. Anyone who has found a work around?

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

{{ h_content | replace: '\/\/d1liekpayvooaz.cloudfront.net\/apps\/customizery\/customizery.js?shop=xyz.myshopify.com', ''}}

Hi Mfcss

The JS files are loaded according to each theme’s setup. However, the score on Lighthouse may not fully reflect the store’s actual speed. Generally, a store only needs a score of 50 on mobile and 80 on desktop for good performance.

In my opinion, you should minimize the use of third-party apps, avoid putting too much content on a single page, and refrain from using external libraries like jQuery. This will help ensure the store has the best possible speed.

Best,
Esther