Skip to content

Instantly share code, notes, and snippets.

@panoply
Created December 17, 2018 08:01
Show Gist options
  • Save panoply/56b0cf8556c63361f30d66f27966d773 to your computer and use it in GitHub Desktop.
Save panoply/56b0cf8556c63361f30d66f27966d773 to your computer and use it in GitHub Desktop.
Minify Shopify content_for_header

Minify Content For Header

Shopify requires merchants to include the liquid tag content_for_header in the <head> element of your theme. This is fine and dandy but what Shitify Shopify fails to do is minify this section of code. One can argue that the performance issues regarding this are so minimal that it doesn't really matter but EVERY MILLISECOND COUNTS when you're using this slow SaaS platform.

The below code will minify this section.

{%- capture content_for_header -%}
{{ content_for_header | replace: ' ', '' | strip_newlines }}
{%- endcapture -%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment