Removing unnecessary line spaces from source code

Hello,

When we examine the source code of one of our Shopify stores, we see that there are too many line spaces and we want to remove it.
As far as I know, these spaces belong to liquid codes. Is there a way to remove blank lines?

I’ve tried Liquid filters but they don’t work. Like replace, strip.

https://gyazo.com/dfed59f24dffb1eb79db10508fb294b6

Thanks,
Berk

@berkbelcioglu
Hi you have to use some code beautify to remove spaces.
check out this link

I hope this will work.
Thank you

Shopify liquid tags can be used to remove surround whitespace.
For example:

{% this code won't remove whitespace %}

{% between %}

{% the lines %}

vs this:

{%- this code WILL remove whitespace -%}

{%- between -%}

{%- the lines -%}

See this page for more info:
https://shopify.github.io/liquid/basics/whitespace/

And yes you can get fancy by capturing the entire html output in theme.liquid and parsing the spaces out but that isn’t a path I’d recommend unless you full control the codebase. It’s too easy for an error to be made if the code is a little inconsistent.

Out of interest, why does the space matter? It won’t be adding that much more data to download so if it’s for speed I would suspect there’s much bigger wins for you to look at first. You’d start getting into this kind of optimisation when you’re starting to run out of things to tweak.

Thanks a lot, this solution worked for me.

The source code of our homepage has dropped from 30k to 9k lines.