Performance and caching
Pages are cached and shared by every visitor - what that means for markup, images, scripts and data.
A ShopDepot store serves most pages as finished HTML from a cache, and every section as a cached fragment. A fast theme works with that instead of against it.
The page is the same for everyone
The home page, offer pages, categories, content pages, feature pages and the blog are rendered once and served to every visitor until something they show changes. The platform clears exactly the affected pages when the merchant edits an offer, a category, a menu, the theme or its settings, and rebuilds them in the background.
So your markup must not depend on the visitor:
- No cart data in sections. Outside the cart page
cartis empty on purpose. Read the count and the drawer contents from/cart.js. - No "logged in as". Show account links, and personalise in the browser if you must.
- No wishlist state. Mark hearts from
/wishlist.js. - No CSRF tokens in forms. Storefront forms are protected by origin checks instead.
- No
random(), no "now". A random pick or a countdown computed on the server is frozen for everyone until the next rebuild. Do it in JavaScript.
The cart page, checkout, accounts and search are never cached.
Data from functions is tracked
Each section records what it read - this offer, that category, the catalogue, a menu - and its cached fragment is cleared when that data changes. Read data through objects and the data functions, and the cache stays correct without you doing anything. Data you hard-code into a section (an offer handle in a template) is not tracked.
Images
Every <img> and <iframe> without a loading attribute is made lazy by the platform (loading="lazy", decoding="async") before the page is sent. That is right for almost every image - and wrong for the first one on the screen, which becomes the Largest Contentful Paint.
Important
Give the image above the fold fetchpriority="high" or loading="eager", or it will wait for the lazy loader: the hero image, the first gallery picture of an offer, the cover of a post.
{{ product.featuredMedia|image_url(width: 1600)|image_tag(alt: product.title, loading: 'eager', sizes: '(min-width: 900px) 50vw, 100vw') }}
Ask for the width you show: |image_url(width: 800) for a card, 1600 for a hero. Give width and height (or an aspect-ratio in CSS) so the layout does not jump while images load. Images come from the store CDN on its own host; the platform adds a preconnect for it.
HTML is minified
Storefront HTML is minified before it is sent: comments go, whitespace collapses to one space, and no space is kept next to block elements. Do not rely on a line break in a template for a visible gap - use CSS gap or margin. Inline JavaScript is minified too; template literals and type="text/template" scripts are left alone.
CSS and JavaScript
- Section and block CSS in
{% stylesheet %}ends up in one cached file. Keep the theme stylesheet lean and avoid importing large frameworks. - Load scripts as deferred modules. Nothing should block the first render.
- Self-host fonts, preload one file, and use
font-display: swap. See Assets. - Do not load third-party scripts from the theme. Merchants add tracking and widgets themselves, with consent.
Large catalogues
Stores can have tens of thousands of offers and hundreds of categories. Never render a full category tree into every page: use menu levels on demand. Lists are paginated by the platform; respect pagination instead of asking for more.
Addresses
Every store address ends with a slash - /cart/, /products/example/, /blog/. Write links that way, or the visitor gets an extra redirect. Files (/cart.js, asset_url addresses) do not.