Shopify Best Practices
Avoid abbreviations
Why? It is easier to read and understand (settings, metafields, variables).
{% comment %}bad{% endcomment %}
{%- assign cta = section.settings.cta -%}
{% comment %}good{% endcomment %}
{%- assign button_text = section.settings.button_text -%}
One level of indentation
Why? It helps to improve the design of our code.
{% comment %}bad{% endcomment %}
{%- for block in section.blocks -%}
{%- if block.settings != blank and block.settings != blank -%}
<div>
<h2>{{- block.settings.title -}}</h2>
<div>{{- block.settings.description -}}</div>
</div>
{%- endif -%}
{%- endfor -%}
{% comment %}good{% endcomment %}
{%- for block in section.blocks -%}
{%- if block.settings.title == blank or block.settings.description == blank -%}
{%- continue -%}
{%- endif -%}
<div>
<h2>{{- block.settings.title -}}</h2>
<div>{{- block.settings.description -}}</div>
</div>
{%- endfor -%}
Performance
Code splitting
Consider using code splitting when one single bundle is too big and the performance of the site is affected.
https://gitlab.com/miguel.montalvo/theme-code-splitting/blob/master/workshop.md
Tools
Edited by Miguel Montalvo