A space to discuss online store customization, theme development, and Liquid templating.
I'm new to Shopify and have been trying to optimise the performance for two days, but I've failed because the content_for_header object returns too many scripts (JavaScript). Now that I've removed content_for_header from one page, my page speed has improved. But I'm not sure what kind of scripts are returned by these objects or what effect they will have on the entire website if I remove them permanently.
Could you please tell me whether I should remove this? And what effect will these scripts have?
Second, can you tell me what the purpose of these scripts returned by the content_for_header object is and where I can learn more about their functionality? Or can I add attributes like defer to these scripts????
It's not something you want to remove unless you really, really know the impact. Removal could see things like accelerated payments, app code, tracking/reporting scripts not load. Not loading those can equal more speed (obviously, since you're loading less) but at the loss of functionality you likely want to keep to running the business.
Great that you're looking at speed but don't over index on that at the cost of core functionality for a commerce site.
Thank you for your response, but the problem is that content_for_header is injecting third-party code into the page . Could you please tell us what we should do to lessen the impact of third-party code? As shown in the image below, all of this content is returned by the content_for_header object.
Furthermore, Shopify does not provide a solution to the
deal with issues such as (serve static assets with efficient cache policy).
I believe that Shopify's services are so poor that we are forced to use third-party plugins to optimise speed.