Skip to content
shopdepot.dev

Themes

Assets and fonts

CSS, JavaScript, images and fonts in assets/, how they are served and how to load them.

View as Markdown

Everything the browser loads from your theme lives in assets/, in folders if you like: assets/css/theme.css, assets/js/theme.js, assets/fonts/, assets/img/.

Referencing an asset

asset_url takes the path inside assets/:

{{ 'css/theme.css'|asset_url|stylesheet_tag }}
{{ 'js/theme.js'|asset_url|script_tag }}
<img src="{{ 'img/badge.svg'|asset_url }}" alt="" width="48" height="48">

The address contains a fingerprint of the theme version and is served from the store CDN with a cache lifetime of a year. A new version of your theme gets a new fingerprint, so browsers fetch the changed files at once and nothing ever needs a cache-busting query string.

In CSS, use relative paths between files in assets/ - url("../fonts/example.woff2") from assets/css/theme.css.

JavaScript

Ship plain ES modules. script_tag produces <script type="module" defer>. There is no bundler in the platform: if you use one locally, commit its output to assets/.

Keep scripts small and progressive. Every storefront page must work without JavaScript for the basics - links, the add-to-cart form, search - and use scripts to make them nicer. The platform's own forms (contact, newsletter) already work both ways.

Fonts

Self-host fonts in assets/fonts/ as woff2 and declare them with @font-face in your brand tokens snippet, so the platform's pages in the store use them too. Preload the one file the first screen needs:

<link rel="preload" href="{{ 'fonts/example-latin.woff2'|asset_url }}" as="font" type="font/woff2" crossorigin>

Use font-display: swap and split large fonts by unicode-range (latin, latin-ext) so a store in Polish does not download Cyrillic. Make sure the font licence allows web embedding and redistribution with a theme.

Images that belong to the theme

Decorations - a pattern, an icon, an illustration - go in assets/img/. Images that are content - a hero photo, a banner - are settings (image_picker), uploaded by the merchant to their media library. A theme that ships content images in assets/ forces the merchant to edit code to change them.

Every PNG and JPG in assets/ gets a WebP copy when the theme is saved, if the copy is at least 10% smaller. asset_url then gives the address of the WebP file. Keep writing .png and .jpg in templates and settings; you do not ship WebP files yourself. GIF files and demo/assets/ stay as they are.

The platform logo fallback for its own pages in the store is assets/img/logo.svg - see Platform pages.

Limits

  • 2 MB per binary file, 256 KB per text file.
  • Binary types: png, jpg, jpeg, gif, webp, avif, ico, woff, woff2, ttf, otf, eot. SVG is text.
  • Lowercase paths, at most four levels from the theme root (assets/img/icons/cart.svg).