Does anyone know how to use this {{ content_for_header }} ?

Highlighted
Excursionist
30 0 4

Hi, all?

Does anyone know how to use {{ content_for_header }} ? Is there any error on my syntax in the following code?

I wrote the following code for my website to try to stop loading these 4 apps on my home page and 2 apps on my collection page.

But this code doesn’t work. Would you please tell me what is wrong?

<head>

....


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

{% if template == "index" %}
{{ h_content | remove: "https:\\connect.facebook.net\signals\config\581739415821802?v=2.9.23&r=stable" }}
{{ h_content | remove: "https:\\brain-assets.boldapps.net\js\widget.js?shop=forevershop.myshopify.com" }}
{{ h_content | remove: "https:\\sdk.beeketing.com\js\beeketing.js?20200901" }}
{{ h_content | remove: "https:\\www.gstatic.com\recaptcha\releases\QVh-Tz10ahidjrORgXOS1oB0\recaptcha__en.js" }}
{% elsif template == "collection" %}
{{ h_content | remove: "https:\\connect.facebook.net\signals\config\581739415821802?v=2.9.23&r=stable" }}
{{ h_content | remove: "https:\\brain-assets.boldapps.net\js\widget.js?shop=forevershop.myshopify.com" }}

{% else %}
{{ content_for_header }}
{{ content_for_footer }}
{% endif %}

.....

</head>

After I inserted this code into my theme (Old version of Minimal ) and then tested my website: https://iloveforeverfashion.com/ from Google PageSpeed Insights, I still saw that google suggested to eliminate these javascripts. That means these apps: facebook app, brain bold app, beeketing app, and recaptcha app are still working when loading my home page.

Would you please help me?

Thanks!

Jane 09/02/2020

1 Like